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

pr-pull: add --no-cherry-pick flag #15011

Merged
merged 2 commits into from Mar 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions Library/Homebrew/dev-cmd/pr-pull.rb
Expand Up @@ -22,6 +22,8 @@ def self.pr_pull_args
description: "Download the bottles but don't upload them."
switch "--no-commit",
description: "Do not generate a new commit before uploading."
switch "--no-cherry-pick",
description: "Do not cherry-pick commits from the pull request branch."
switch "-n", "--dry-run",
description: "Print what would be done rather than doing it."
switch "--clean",
Expand Down Expand Up @@ -447,10 +449,16 @@ def self.pr_pull
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
Comment on lines +453 to +455
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed because if we used the original definition of original_commit, #formulae_need_bottles? below mistakenly returns false. Looking at c669f1d might give more context here.

else
current_branch_head
end

unless args.no_commit?
cherry_pick_pr!(user, repo, pr, path: tap.path, args: args)
cherry_pick_pr!(user, repo, pr, path: tap.path, args: args) unless args.no_cherry_pick?
if !args.no_autosquash? && !args.dry_run?
autosquash!(original_commit, tap: tap,
verbose: args.verbose?, resolve: args.resolve?, reason: args.message)
Expand Down