diff options
| author | Mike McQuaid | 2016-10-22 12:10:48 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2016-10-22 12:10:48 +0100 |
| commit | 0c661f5c901e7344f59c70526f45097e5e44af7a (patch) | |
| tree | 4717fb3624b2e84de254e6f9123725778960b1c9 /Library/Homebrew/dev-cmd | |
| parent | 0296439c832a915be9b73456c0c26bc6c79c271d (diff) | |
| download | brew-0c661f5c901e7344f59c70526f45097e5e44af7a.tar.bz2 | |
Add `brew release-notes` developer command.
Outputs the merged pull requests on Homebrew/brew between two Git refs.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
| -rw-r--r-- | Library/Homebrew/dev-cmd/release-notes.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb new file mode 100644 index 000000000..919243764 --- /dev/null +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -0,0 +1,43 @@ +#: * `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. + +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 |
