dev-cmd/pr-pull: use commit message helper

This commit is contained in:
Jonathan Chang 2020-09-19 17:02:28 +10:00
parent cdfb1badcf
commit 0bb2c96cfc

View File

@ -99,8 +99,7 @@ module Homebrew
end end
def signoff!(pr, tap:, args:) def signoff!(pr, tap:, args:)
message = Utils.popen_read "git", "-C", tap.path, "log", "-1", "--pretty=%B" subject, body, trailers = separate_commit_message(Utils::Git.commit_message(tap.path))
subject, body, trailers = separate_commit_message(message)
# Approving reviewers also sign-off on merge. # Approving reviewers also sign-off on merge.
trailers += GitHub.approved_reviews(tap.user, "homebrew-#{tap.repo}", pr).map do |r| trailers += GitHub.approved_reviews(tap.user, "homebrew-#{tap.repo}", pr).map do |r|
@ -156,8 +155,7 @@ module Homebrew
new_formula = Utils::Git.file_at_commit(path, file, "HEAD") new_formula = Utils::Git.file_at_commit(path, file, "HEAD")
bump_subject = determine_bump_subject(old_formula, new_formula, formula_file, reason: args.message) bump_subject = determine_bump_subject(old_formula, new_formula, formula_file, reason: args.message)
message = Utils.popen_read("git", "-C", path, "log", "-1", "--pretty=%B") subject, body, trailers = separate_commit_message(Utils::Git.commit_message(path))
subject, body, trailers = separate_commit_message(message)
if subject != bump_subject && !subject.start_with?("#{formula_name}:") if subject != bump_subject && !subject.start_with?("#{formula_name}:")
safe_system("git", "-C", path, "commit", "--amend", "-q", safe_system("git", "-C", path, "commit", "--amend", "-q",
@ -182,8 +180,7 @@ module Homebrew
messages = [] messages = []
trailers = [] trailers = []
commits.each do |commit| commits.each do |commit|
original_message = Utils.safe_popen_read("git", "-C", path, "show", "--no-patch", "--pretty=%B", commit) subject, body, trailer = separate_commit_message(Utils::Git.commit_message(path, commit))
subject, body, trailer = separate_commit_message(original_message)
body = body.lines.map { |line| " #{line.strip}" }.join("\n") body = body.lines.map { |line| " #{line.strip}" }.join("\n")
messages << "* #{subject}\n#{body}".strip messages << "* #{subject}\n#{body}".strip
trailers << trailer trailers << trailer