From 0c661f5c901e7344f59c70526f45097e5e44af7a Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 22 Oct 2016 12:10:48 +0100 Subject: [PATCH] Add `brew release-notes` developer command. Outputs the merged pull requests on Homebrew/brew between two Git refs. --- Library/Homebrew/dev-cmd/release-notes.rb | 43 +++++++++++++++++++++++ docs/brew.1.html | 5 +++ manpages/brew.1 | 7 ++++ 3 files changed, 55 insertions(+) create mode 100644 Library/Homebrew/dev-cmd/release-notes.rb diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb new file mode 100644 index 0000000000..9192437648 --- /dev/null +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -0,0 +1,43 @@ +#: * `release-notes` [] []: +#: Output the merged pull requests on Homebrew/brew between two Git refs. +#: If no `previous_tag` is provided it defaults to the newest tag. +#: If no `end_ref` is provided it defaults to `origin/master`. +#: +#: If `--markdown` is passed, output as a Markdown list. + +module Homebrew + module_function + + def release_notes + previous_tag = ARGV.named.first + unless previous_tag + previous_tag = Utils.popen_read("git tag --list --sort=-version:refname") + .lines.first.chomp + end + odie "Could not find any previous tags!" unless previous_tag + + end_ref = ARGV.named[1] || "origin/master" + + [previous_tag, end_ref].each do |ref| + next if quiet_system "git", "rev-parse", "--verify", "--quiet", ref + odie "Ref #{ref} does not exist!" + end + + output = Utils.popen_read("git log --pretty=format:'%s >> - %b%n' '#{previous_tag}'..'#{end_ref}'") + .lines.grep(/Merge pull request/) + + output.map! do |s| + s.gsub(/.*Merge pull request #(\d+)[^>]*(>>)*/, + "https://github.com/Homebrew/brew/pull/\\1") + end + if ARGV.include?("--markdown") + output.map! do |s| + /(.*\d)+ - (.*)/ =~ s + "- [#{$2}](#{$1})" + end + end + + puts "Release notes between #{previous_tag} and #{end_ref}:" + puts output + end +end diff --git a/docs/brew.1.html b/docs/brew.1.html index 59c29cb3a4..bb8775cebe 100644 --- a/docs/brew.1.html +++ b/docs/brew.1.html @@ -567,6 +567,11 @@ Each <patch-source> may be one of: If --no-publish was passed, do not publish bottles to Bintray.

+
release-notes [previous_tag] [end_ref]

Output the merged pull requests on Homebrew/brew between two Git refs. +If no previous_tag is provided it defaults to the newest tag. +If no end_ref is provided it defaults to origin/master.

+ +

If --markdown is passed, output as a Markdown list.

tap-new user/repo

Generate the template files for a new tap.

test [--devel|--HEAD] [--debug] [--keep-tmp] formula

Most formulae provide a test method. brew test formula runs this test method. There is no standard output or return code, but it should diff --git a/manpages/brew.1 b/manpages/brew.1 index ca98390a69..c74969aee7 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -759,6 +759,13 @@ Each may be one of: If \fB\-\-bottle\fR was passed, handle bottles, pulling the bottle\-update commit and publishing files on Bintray\. If \fB\-\-bump\fR was passed, for one\-formula PRs, automatically reword commit message to our preferred format\. If \fB\-\-clean\fR was passed, do not rewrite or otherwise modify the commits found in the pulled PR\. If \fB\-\-ignore\-whitespace\fR was passed, silently ignore whitespace discrepancies when applying diffs\. If \fB\-\-resolve\fR was passed, when a patch fails to apply, leave in progress and allow user to resolve, instead of aborting\. If \fB\-\-branch\-okay\fR was passed, do not warn if pulling to a branch besides master (useful for testing)\. If \fB\-\-no\-pbcopy\fR was passed, do not copy anything to the system If \fB\-\-no\-publish\fR was passed, do not publish bottles to Bintray\. . .TP +\fBrelease\-notes\fR [\fIprevious_tag\fR] [\fIend_ref\fR] +Output the merged pull requests on Homebrew/brew between two Git refs\. If no \fBprevious_tag\fR is provided it defaults to the newest tag\. If no \fBend_ref\fR is provided it defaults to \fBorigin/master\fR\. +. +.IP +If \fB\-\-markdown\fR is passed, output as a Markdown list\. +. +.TP \fBtap\-new\fR \fIuser\fR\fB/\fR\fIrepo\fR Generate the template files for a new tap\. .