Skip to content
Snippets Groups Projects
Commit 07efe1e7 authored by Jason Karns's avatar Jason Karns
Browse files

bump-formula-pr now creates non-tracking branches

Without `--no-track`, some git setups may automatically set
`origin/master` as the tracked upstream for the newly created branch.
This upstream is what hub defaults as --head when opening PRs. By not
allowing git to set `origin/master` as upstream, hub can then use the
proper --head for the PR.

Since hub still needs to know what --head is intended to be, we can set
the branch's upstream when pushing: with the --set-upstream option.

Fixes #755
parent 105d7aa5
No related branches found
No related tags found
No related merge requests found
......@@ -140,15 +140,15 @@ module Homebrew
formula.path.parent.cd do
branch = "#{formula.name}-#{new_formula_version}"
if ARGV.dry_run?
ohai "git checkout -b #{branch} origin/master"
ohai "git checkout --no-track -b #{branch} origin/master"
ohai "git commit --no-edit --verbose --message='#{formula.name} #{new_formula_version}#{devel_message}' -- #{formula.path}"
ohai "hub fork --no-remote"
ohai "hub fork"
ohai "hub fork (to read $HUB_REMOTE)"
ohai "git push $HUB_REMOTE #{branch}:#{branch}"
ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}"
ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'"
else
safe_system "git", "checkout", "-b", branch, "origin/master"
safe_system "git", "checkout", "--no-track", "-b", branch, "origin/master"
safe_system "git", "commit", "--no-edit", "--verbose",
"--message=#{formula.name} #{new_formula_version}#{devel_message}",
"--", formula.path
......@@ -156,7 +156,7 @@ module Homebrew
quiet_system "hub", "fork"
remote = Utils.popen_read("hub fork 2>&1")[/fatal: remote (.+) already exists\./, 1]
odie "cannot get remote from 'hub'!" if remote.to_s.empty?
safe_system "git", "push", remote, "#{branch}:#{branch}"
safe_system "git", "push", "--set-upstream", remote, "#{branch}:#{branch}"
safe_system "hub", "pull-request", "--browse", "-m",
"#{formula.name} #{new_formula_version}#{devel_message}\n\nCreated with `brew bump-formula-pr`."
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment