Merge pull request #8179 from SeekingMeaning/bump-formula-pr/base-branch

bump-formula-pr: open PR on default branch
This commit is contained in:
Seeker 2020-08-03 12:53:37 -07:00 committed by GitHub
commit 5c6eda8dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,7 +105,10 @@ module Homebrew
end end
end end
end end
[formula.tap&.full_name, "origin/master", "-"] origin_branch = Utils.popen_read("git", "-C", formula.tap.path.to_s, "symbolic-ref", "-q", "--short",
"refs/remotes/origin/HEAD").chomp.presence
origin_branch ||= "origin/master"
[formula.tap&.full_name, origin_branch, "-"]
end end
def bump_formula_pr def bump_formula_pr
@ -338,6 +341,7 @@ module Homebrew
run_audit(formula, alias_rename, old_contents, args: args) run_audit(formula, alias_rename, old_contents, args: args)
formula.path.parent.cd do formula.path.parent.cd do
_, base_branch = origin_branch.split("/")
branch = "bump-#{formula.name}-#{new_formula_version}" branch = "bump-#{formula.name}-#{new_formula_version}"
git_dir = Utils.popen_read("git rev-parse --git-dir").chomp git_dir = Utils.popen_read("git rev-parse --git-dir").chomp
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow") shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
@ -353,7 +357,7 @@ module Homebrew
"#{new_formula_version}' -- #{changed_files.join(" ")}" "#{new_formula_version}' -- #{changed_files.join(" ")}"
ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}" ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}"
ohai "git checkout --quiet #{previous_branch}" ohai "git checkout --quiet #{previous_branch}"
ohai "create pull request with GitHub API" ohai "create pull request with GitHub API (base branch: #{base_branch})"
else else
if args.no_fork? if args.no_fork?
@ -386,7 +390,7 @@ module Homebrew
begin begin
url = GitHub.create_pull_request(tap_full_name, pr_title, url = GitHub.create_pull_request(tap_full_name, pr_title,
"#{username}:#{branch}", "master", pr_message)["html_url"] "#{username}:#{branch}", base_branch, pr_message)["html_url"]
if args.no_browse? if args.no_browse?
puts url puts url
else else