mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

This was failing for me locally so I've made some fixes: - remove the `markdown` flag (as it's the only path now) - refactor the generation to not use intermediate variables - discard more weird cases rather than erroring - exclude @Homebrew changes (e.g. from bots) because we don't care about these in the release notes
31 lines
949 B
Ruby
31 lines
949 B
Ruby
# typed: true
|
|
# frozen_string_literal: true
|
|
|
|
# Helper functions for generating release notes.
|
|
#
|
|
# @api private
|
|
module ReleaseNotes
|
|
extend T::Sig
|
|
|
|
module_function
|
|
|
|
sig {
|
|
params(start_ref: T.any(String, Version), end_ref: T.any(String, Version), markdown: T.nilable(T::Boolean))
|
|
.returns(String)
|
|
}
|
|
def generate_release_notes(start_ref, end_ref, markdown: false)
|
|
Utils.popen_read(
|
|
"git", "-C", HOMEBREW_REPOSITORY, "log", "--pretty=format:'%s >> - %b%n'", "#{start_ref}..#{end_ref}"
|
|
).lines.map do |s|
|
|
matches = s.match(%r{.*Merge pull request #(?<pr>\d+) from (?<user>[^/]+)/[^>]*>> - (?<body>.*)})
|
|
next if matches.blank?
|
|
next if matches[:user] == "Homebrew"
|
|
|
|
body = matches[:body].presence
|
|
body ||= s.gsub(/.*(Merge pull request .*) >> - .*/, "\\1").chomp
|
|
|
|
"- [#{body}](https://github.com/Homebrew/brew/pull/#{matches[:pr]}) (@#{matches[:user]})\n"
|
|
end.compact.join
|
|
end
|
|
end
|