Use git merge-base to determine original_commit

This commit is contained in:
Carlo Cabrera 2023-03-20 00:55:20 +08:00
parent c669f1d625
commit e5b9e97b92
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0

View File

@ -449,7 +449,13 @@ module Homebrew
ohai "Fetching #{tap} pull request ##{pr}"
Dir.mktmpdir pr do |dir|
cd dir do
original_commit = ENV["GITHUB_SHA"].presence || tap.path.git_head
current_branch_head = ENV["GITHUB_SHA"] || tap.git_head
original_commit = if args.no_cherry_pick?
# TODO: Handle the case where `merge-base` returns multiple commits.
Utils.safe_popen_read("git", "-C", tap.path, "merge-base", "origin/HEAD", current_branch_head).strip
else
current_branch_head
end
unless args.no_commit?
cherry_pick_pr!(user, repo, pr, path: tap.path, args: args) unless args.no_cherry_pick?
@ -460,13 +466,7 @@ module Homebrew
signoff!(tap.path, pr: pr, dry_run: args.dry_run?) unless args.clean?
end
# TODO: Fix determination of `original_commit` above for the `--no-cherry-pick` flag.
# When we pull to the PR branch that contains the commits we want to merge,
# `#formulae_need_bottles?` mistakenly returns `true`, because it thinks
# that no formulae have changed. We probably want to use the commit identified
# by `git merge-base`.
if !formulae_need_bottles?(tap, original_commit, user, repo, pr, args: args) &&
!args.no_cherry_pick?
unless formulae_need_bottles?(tap, original_commit, user, repo, pr, args: args)
ohai "Skipping artifacts for ##{pr} as the formulae don't need bottles"
next
end