aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd
diff options
context:
space:
mode:
authorMike McQuaid2016-10-22 13:40:05 +0100
committerGitHub2016-10-22 13:40:05 +0100
commit22182403c5b76cc9f1a069738085a7b13df3507e (patch)
tree9b3d00e5995336ce52d43f13abece4f938c3f9f1 /Library/Homebrew/dev-cmd
parent5b421b93c9897dd5bae60c24bb937cccdafa5574 (diff)
parent0c661f5c901e7344f59c70526f45097e5e44af7a (diff)
downloadbrew-22182403c5b76cc9f1a069738085a7b13df3507e.tar.bz2
Merge pull request #1310 from MikeMcQuaid/changelog
Add `brew release-notes` developer command.
Diffstat (limited to 'Library/Homebrew/dev-cmd')
-rw-r--r--Library/Homebrew/dev-cmd/release-notes.rb43
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