From 76c69b7bb35077bbb94c8f6337bc1899b2b71b63 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 23 Dec 2020 11:17:51 -0500 Subject: [PATCH 1/8] release-notes: add message directing users to the blog. --- Library/Homebrew/dev-cmd/release-notes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index 26cbe6e5e1..dd72599bb3 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -58,6 +58,7 @@ module Homebrew end $stderr.puts "Release notes between #{previous_tag} and #{end_ref}:" + puts "Release notes for major and minor releases can be found in the [Homebrew blog](https://brew.sh/blog/)." puts output end end From 9fd2319afa9ad3c40b365bff7e5668f640aed82b Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Wed, 23 Dec 2020 12:06:28 -0500 Subject: [PATCH 2/8] update-report: add links to changelog and blog --- Library/Homebrew/cmd/update-report.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 78e39ae50c..364e7ea85a 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -78,6 +78,7 @@ module Homebrew install_core_tap_if_necessary updated = false + new_repository_version = nil initial_revision = ENV["HOMEBREW_UPDATE_BEFORE"].to_s current_revision = ENV["HOMEBREW_UPDATE_AFTER"].to_s @@ -87,6 +88,9 @@ module Homebrew update_preinstall_header args: args puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true + + tag = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD") + new_repository_version = tag.chomp if tag.present? end Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] @@ -136,6 +140,21 @@ module Homebrew Commands.rebuild_commands_completion_list link_completions_manpages_and_docs Tap.each(&:link_completions_and_manpages) + + return if new_repository_version.blank? + + ohai "Homebrew was updated to version #{new_repository_version}" + puts <<~EOS + The changelog can be found at: + #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} + EOS + + return unless new_repository_version.split(".").last == "0" + + puts <<~EOS + More detailed release notes are available on the Homebrew Blog: + #{Formatter.url("https://brew.sh/blog/")} + EOS end def shorten_revision(revision) From a0e663d833f9a320cd50ab63d6b904b4fdd5f51b Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Thu, 24 Dec 2020 19:05:23 -0500 Subject: [PATCH 3/8] update: show either changelog or release noted link --- Library/Homebrew/cmd/update-report.rb | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 364e7ea85a..d2af1451f1 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -89,8 +89,7 @@ module Homebrew puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true - tag = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD") - new_repository_version = tag.chomp if tag.present? + new_repository_version = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD").chomp.presence end Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] @@ -144,17 +143,17 @@ module Homebrew return if new_repository_version.blank? ohai "Homebrew was updated to version #{new_repository_version}" - puts <<~EOS - The changelog can be found at: - #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} - EOS - - return unless new_repository_version.split(".").last == "0" - - puts <<~EOS - More detailed release notes are available on the Homebrew Blog: - #{Formatter.url("https://brew.sh/blog/")} - EOS + if new_repository_version.split(".").last == "0" + puts <<~EOS + More detailed release notes are available on the Homebrew Blog: + #{Formatter.url("https://brew.sh/blog/")} + EOS + else + puts <<~EOS + The changelog can be found at: + #{Formatter.url("https://github.com/Homebrew/brew/releases/tag/#{new_repository_version}")} + EOS + end end def shorten_revision(revision) From 97f8d095194dc5448c9b80bc66ccba984a7b1f51 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 25 Dec 2020 13:51:48 -0500 Subject: [PATCH 4/8] release-notes: only show blog link when previous_tag passed --- Library/Homebrew/dev-cmd/release-notes.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index dd72599bb3..925433ca87 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -58,7 +58,9 @@ module Homebrew end $stderr.puts "Release notes between #{previous_tag} and #{end_ref}:" - puts "Release notes for major and minor releases can be found in the [Homebrew blog](https://brew.sh/blog/)." + if args.markdown? && args.named.first + puts "Release notes for major and minor releases can be found in the [Homebrew blog](https://brew.sh/blog/)." + end puts output end end From 5b360f35c534a881e045fd51474e3982dad63c11 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Fri, 25 Dec 2020 14:08:11 -0500 Subject: [PATCH 5/8] update-report: use gitconfig to remember last tag --- Library/Homebrew/cmd/update-report.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index d2af1451f1..bd151d5d6a 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -89,7 +89,21 @@ module Homebrew puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." updated = true - new_repository_version = Utils.safe_popen_read("git", "tag", "--points-at", "HEAD").chomp.presence + old_tag = if (HOMEBREW_REPOSITORY/".git/config").exist? + Utils.popen_read( + "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", "--get", "homebrew.latesttag" + ).chomp.presence + end + + new_tag = Utils.popen_read( + "git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname" + ).lines.first.chomp + + if new_tag != old_tag + system "git", "config", "--file=#{HOMEBREW_REPOSITORY}/.git/config", + "--replace-all", "homebrew.latesttag", new_tag + new_repository_version = new_tag + end end Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] From a33f4e0fd1faf60289903cacc89f649739c1b849 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 28 Dec 2020 10:37:09 -0500 Subject: [PATCH 6/8] release-notes: show warning on recent major/minor tag --- Library/Homebrew/dev-cmd/release-notes.rb | 13 +++++++++++++ docs/Manpage.md | 4 ++++ manpages/brew.1 | 3 +++ 3 files changed, 20 insertions(+) diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index 925433ca87..1c9069af25 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -17,6 +17,10 @@ module Homebrew Print the merged pull requests on Homebrew/brew between two Git refs. If no is provided it defaults to the latest tag. If no is provided it defaults to `origin/master`. + + If `--markdown` and a are passed, an extra line containg + a link to the Homebrew blog will be adding to the output. Additionally, + a warning will be shown if the latest minor release was less than one month ago. EOS switch "--markdown", description: "Print as a Markdown list." @@ -29,6 +33,15 @@ module Homebrew args = release_notes_args.parse previous_tag = args.named.first + + if previous_tag.present? + + previous_tag_date = Date.parse Utils.popen_read( + "git", "-C", HOMEBREW_REPOSITORY, "log", "-1", "--format=%aI", previous_tag.sub(/\d+$/, "0") + ) + opoo "The latest major/minor release was less than one month ago." if previous_tag_date > (Date.today << 1) + end + previous_tag ||= Utils.popen_read( "git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname" ).lines.first.chomp diff --git a/docs/Manpage.md b/docs/Manpage.md index 7bc638a186..edcf3931b1 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1197,6 +1197,10 @@ Print the merged pull requests on Homebrew/brew between two Git refs. If no *`previous_tag`* is provided it defaults to the latest tag. If no *`end_ref`* is provided it defaults to `origin/master`. +If `--markdown` and a *`previous_tag`* are passed, an extra line containg +a link to the Homebrew blog will be adding to the output. Additionally, +a warning will be shown if the latest minor release was less than one month ago. + * `--markdown`: Print as a Markdown list. diff --git a/manpages/brew.1 b/manpages/brew.1 index 5a8a4b8b13..b5f5de5e18 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1672,6 +1672,9 @@ Use \fBstackprof\fR instead of \fBruby\-prof\fR (the default)\. .SS "\fBrelease\-notes\fR [\fIoptions\fR] [\fIprevious_tag\fR] [\fIend_ref\fR]" Print the merged pull requests on Homebrew/brew between two Git refs\. If no \fIprevious_tag\fR is provided it defaults to the latest tag\. If no \fIend_ref\fR is provided it defaults to \fBorigin/master\fR\. . +.P +If \fB\-\-markdown\fR and a \fIprevious_tag\fR are passed, an extra line containg a link to the Homebrew blog will be adding to the output\. Additionally, a warning will be shown if the latest minor release was less than one month ago\. +. .TP \fB\-\-markdown\fR Print as a Markdown list\. From 80d8b419de729b6fed3ca1d139756bb9780ba3ef Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 28 Dec 2020 10:56:07 -0500 Subject: [PATCH 7/8] update-report: update blog post link --- Library/Homebrew/cmd/update-report.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index bd151d5d6a..3de77a5237 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -160,7 +160,7 @@ module Homebrew if new_repository_version.split(".").last == "0" puts <<~EOS More detailed release notes are available on the Homebrew Blog: - #{Formatter.url("https://brew.sh/blog/")} + #{Formatter.url("https://brew.sh/blog/#{new_repository_version}")} EOS else puts <<~EOS From 6d0899f298e455b9e1a4e1c51b9d754af2b05f32 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 28 Dec 2020 11:34:29 -0500 Subject: [PATCH 8/8] release-notes: clarify help text and minor refactor --- Library/Homebrew/dev-cmd/release-notes.rb | 9 +++++---- docs/Manpage.md | 2 +- manpages/brew.1 | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/release-notes.rb b/Library/Homebrew/dev-cmd/release-notes.rb index 1c9069af25..004915f284 100644 --- a/Library/Homebrew/dev-cmd/release-notes.rb +++ b/Library/Homebrew/dev-cmd/release-notes.rb @@ -18,7 +18,7 @@ module Homebrew If no is provided it defaults to the latest tag. If no is provided it defaults to `origin/master`. - If `--markdown` and a are passed, an extra line containg + If `--markdown` and a are passed, an extra line containing a link to the Homebrew blog will be adding to the output. Additionally, a warning will be shown if the latest minor release was less than one month ago. EOS @@ -35,11 +35,12 @@ module Homebrew previous_tag = args.named.first if previous_tag.present? - + most_recent_major_minor_tag = previous_tag.sub(/\d+$/, "0") + one_month_ago = Date.today << 1 previous_tag_date = Date.parse Utils.popen_read( - "git", "-C", HOMEBREW_REPOSITORY, "log", "-1", "--format=%aI", previous_tag.sub(/\d+$/, "0") + "git", "-C", HOMEBREW_REPOSITORY, "log", "-1", "--format=%aI", most_recent_major_minor_tag ) - opoo "The latest major/minor release was less than one month ago." if previous_tag_date > (Date.today << 1) + opoo "The latest major/minor release was less than one month ago." if previous_tag_date > one_month_ago end previous_tag ||= Utils.popen_read( diff --git a/docs/Manpage.md b/docs/Manpage.md index edcf3931b1..9066ac8f3c 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -1197,7 +1197,7 @@ Print the merged pull requests on Homebrew/brew between two Git refs. If no *`previous_tag`* is provided it defaults to the latest tag. If no *`end_ref`* is provided it defaults to `origin/master`. -If `--markdown` and a *`previous_tag`* are passed, an extra line containg +If `--markdown` and a *`previous_tag`* are passed, an extra line containing a link to the Homebrew blog will be adding to the output. Additionally, a warning will be shown if the latest minor release was less than one month ago. diff --git a/manpages/brew.1 b/manpages/brew.1 index b5f5de5e18..ebb9a3daad 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -1673,7 +1673,7 @@ Use \fBstackprof\fR instead of \fBruby\-prof\fR (the default)\. Print the merged pull requests on Homebrew/brew between two Git refs\. If no \fIprevious_tag\fR is provided it defaults to the latest tag\. If no \fIend_ref\fR is provided it defaults to \fBorigin/master\fR\. . .P -If \fB\-\-markdown\fR and a \fIprevious_tag\fR are passed, an extra line containg a link to the Homebrew blog will be adding to the output\. Additionally, a warning will be shown if the latest minor release was less than one month ago\. +If \fB\-\-markdown\fR and a \fIprevious_tag\fR are passed, an extra line containing a link to the Homebrew blog will be adding to the output\. Additionally, a warning will be shown if the latest minor release was less than one month ago\. . .TP \fB\-\-markdown\fR