dev-cmd/pr-pull: don't assume a master branch
This commit is contained in:
parent
415c36041a
commit
04687aef93
@ -35,7 +35,7 @@ module Homebrew
|
||||
description: "Automatically reformat and reword commits in the pull request to our "\
|
||||
"preferred format."
|
||||
switch "--branch-okay",
|
||||
description: "Do not warn if pulling to a branch besides master (useful for testing)."
|
||||
description: "Do not warn if pulling to a branch besides the repository default (useful for testing)."
|
||||
switch "--resolve",
|
||||
description: "When a patch fails to apply, leave in progress and allow user to resolve, "\
|
||||
"instead of aborting."
|
||||
@ -291,14 +291,6 @@ module Homebrew
|
||||
Utils::Git.cherry_pick!(path, "--ff", "--allow-empty", *commits, verbose: args.verbose?, resolve: args.resolve?)
|
||||
end
|
||||
|
||||
def check_branch(path, ref, args:)
|
||||
branch = Utils.popen_read("git", "-C", path, "symbolic-ref", "--short", "HEAD").strip
|
||||
|
||||
return if branch == ref || args.clean? || args.branch_okay?
|
||||
|
||||
opoo "Current branch is #{branch}: do you need to pull inside #{ref}?"
|
||||
end
|
||||
|
||||
def formulae_need_bottles?(tap, original_commit, args:)
|
||||
return if args.dry_run?
|
||||
|
||||
@ -383,7 +375,12 @@ module Homebrew
|
||||
_, user, repo, pr = *url_match
|
||||
odie "Not a GitHub pull request: #{arg}" unless pr
|
||||
|
||||
check_branch tap.path, "master", args: args
|
||||
current_branch = Utils::Git.current_branch(tap.path)
|
||||
origin_branch = Utils::Git.origin_branch(tap.path).split("/").last
|
||||
|
||||
if current_branch != origin_branch || args.branch_okay? || args.clean?
|
||||
opoo "Current branch is #{current_branch}: do you need to pull inside #{origin_branch}?"
|
||||
end
|
||||
|
||||
ohai "Fetching #{tap} pull request ##{pr}"
|
||||
Dir.mktmpdir pr do |dir|
|
||||
|
||||
@ -120,6 +120,10 @@ module Utils
|
||||
"refs/remotes/origin/HEAD").chomp.presence
|
||||
end
|
||||
|
||||
def current_branch(repo)
|
||||
Utils.popen_read("git", "-C", repo, "symbolic-ref", "--short", "HEAD").chomp.presence
|
||||
end
|
||||
|
||||
# Special case of `git cherry-pick` that permits non-verbose output and
|
||||
# optional resolution on merge conflict.
|
||||
def cherry_pick!(repo, *args, resolve: false, verbose: false)
|
||||
|
||||
@ -1101,7 +1101,7 @@ Requires write access to the repository.
|
||||
* `--autosquash`:
|
||||
Automatically reformat and reword commits in the pull request to our preferred format.
|
||||
* `--branch-okay`:
|
||||
Do not warn if pulling to a branch besides master (useful for testing).
|
||||
Do not warn if pulling to a branch besides the repository default (useful for testing).
|
||||
* `--resolve`:
|
||||
When a patch fails to apply, leave in progress and allow user to resolve, instead of aborting.
|
||||
* `--warn-on-upload-failure`:
|
||||
|
||||
@ -1528,7 +1528,7 @@ Automatically reformat and reword commits in the pull request to our preferred f
|
||||
.
|
||||
.TP
|
||||
\fB\-\-branch\-okay\fR
|
||||
Do not warn if pulling to a branch besides master (useful for testing)\.
|
||||
Do not warn if pulling to a branch besides the repository default (useful for testing)\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-resolve\fR
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user