Merge pull request #10117 from Rylan12/add-blog-reference-to-release-notes

Add more links to the changelog and blog
This commit is contained in:
Rylan Polster 2020-12-31 10:46:46 -05:00 committed by GitHub
commit e9a44cb96c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 0 deletions

View File

@ -78,6 +78,7 @@ module Homebrew
install_core_tap_if_necessary install_core_tap_if_necessary
updated = false updated = false
new_repository_version = nil
initial_revision = ENV["HOMEBREW_UPDATE_BEFORE"].to_s initial_revision = ENV["HOMEBREW_UPDATE_BEFORE"].to_s
current_revision = ENV["HOMEBREW_UPDATE_AFTER"].to_s current_revision = ENV["HOMEBREW_UPDATE_AFTER"].to_s
@ -87,6 +88,22 @@ module Homebrew
update_preinstall_header args: args update_preinstall_header args: args
puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}." puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}."
updated = true updated = true
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 end
Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"] Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
@ -136,6 +153,21 @@ module Homebrew
Commands.rebuild_commands_completion_list Commands.rebuild_commands_completion_list
link_completions_manpages_and_docs link_completions_manpages_and_docs
Tap.each(&:link_completions_and_manpages) Tap.each(&:link_completions_and_manpages)
return if new_repository_version.blank?
ohai "Homebrew was updated to version #{new_repository_version}"
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/#{new_repository_version}")}
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 end
def shorten_revision(revision) def shorten_revision(revision)

View File

@ -17,6 +17,10 @@ module Homebrew
Print the merged pull requests on Homebrew/brew between two Git refs. 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 <previous_tag> is provided it defaults to the latest tag.
If no <end_ref> is provided it defaults to `origin/master`. If no <end_ref> is provided it defaults to `origin/master`.
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.
EOS EOS
switch "--markdown", switch "--markdown",
description: "Print as a Markdown list." description: "Print as a Markdown list."
@ -29,6 +33,16 @@ module Homebrew
args = release_notes_args.parse args = release_notes_args.parse
previous_tag = args.named.first 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", most_recent_major_minor_tag
)
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( previous_tag ||= Utils.popen_read(
"git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname" "git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname"
).lines.first.chomp ).lines.first.chomp
@ -58,6 +72,9 @@ module Homebrew
end end
$stderr.puts "Release notes between #{previous_tag} and #{end_ref}:" $stderr.puts "Release notes between #{previous_tag} and #{end_ref}:"
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 puts output
end end
end end

View File

@ -1201,6 +1201,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 *`previous_tag`* is provided it defaults to the latest tag.
If no *`end_ref`* is provided it defaults to `origin/master`. If no *`end_ref`* is provided it defaults to `origin/master`.
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.
* `--markdown`: * `--markdown`:
Print as a Markdown list. Print as a Markdown list.

View File

@ -1680,6 +1680,9 @@ Use \fBstackprof\fR instead of \fBruby\-prof\fR (the default)\.
.SS "\fBrelease\-notes\fR [\fIoptions\fR] [\fIprevious_tag\fR] [\fIend_ref\fR]" .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\. 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 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 .TP
\fB\-\-markdown\fR \fB\-\-markdown\fR
Print as a Markdown list\. Print as a Markdown list\.