Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more links to the changelog and blog #10117

Merged
merged 8 commits into from Dec 31, 2020
32 changes: 32 additions & 0 deletions Library/Homebrew/cmd/update-report.rb
Expand Up @@ -78,6 +78,7 @@ def update_report
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
Expand All @@ -87,6 +88,22 @@ def update_report
update_preinstall_header args: args
puts "Updated Homebrew from #{shorten_revision(initial_revision)} to #{shorten_revision(current_revision)}."
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

Homebrew.failed = true if ENV["HOMEBREW_UPDATE_FAILED"]
Expand Down Expand Up @@ -136,6 +153,21 @@ def update_report
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}"
Rylan12 marked this conversation as resolved.
Show resolved Hide resolved
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

def shorten_revision(revision)
Expand Down
17 changes: 17 additions & 0 deletions Library/Homebrew/dev-cmd/release-notes.rb
Expand Up @@ -17,6 +17,10 @@ def release_notes_args
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 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
switch "--markdown",
description: "Print as a Markdown list."
Expand All @@ -29,6 +33,16 @@ def release_notes
args = release_notes_args.parse

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(
"git", "-C", HOMEBREW_REPOSITORY, "tag", "--list", "--sort=-version:refname"
).lines.first.chomp
Expand Down Expand Up @@ -58,6 +72,9 @@ def release_notes
end

$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
end
end
4 changes: 4 additions & 0 deletions docs/Manpage.md
Expand Up @@ -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 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`:
Print as a Markdown list.

Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Expand Up @@ -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 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
Print as a Markdown list\.
Expand Down