aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMislav Marohnić2017-08-15 17:32:12 +0200
committerMislav Marohnić2017-08-15 17:32:12 +0200
commit80ae5b2660d293adc9d1ad4aaa376500910a339a (patch)
treec084102c72b35513d5eab9875979b2224a0c6ad1
parentdaa0ea4b8a53b3d2965b84ff673c58310a6937ed (diff)
downloadbrew-80ae5b2660d293adc9d1ad4aaa376500910a339a.tar.bz2
bump-formula-pr: forward compatibility with `hub fork`
Due to limitations of `hub fork` in hub 2.2, scripts had to repeat the command at least two times; the 2nd time was to read the fork name from the "fatal: remote MYNAME already exists" message output from git. In upcoming hub 2.3, the `hub fork` command is improved to always output the remote name, regardless of whether one already existed or not. With this approach, only one `hub fork` call will ever be necessary when hub is up to date.
-rw-r--r--Library/Homebrew/dev-cmd/bump-formula-pr.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
index e9e98d450..521c76302 100644
--- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -296,9 +296,7 @@ module Homebrew
ohai "git fetch --unshallow origin" if shallow
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 "hub fork # read $HUB_REMOTE"
ohai "git push --set-upstream $HUB_REMOTE #{branch}:#{branch}"
ohai "hub pull-request --browse -m '#{formula.name} #{new_formula_version}#{devel_message}'"
ohai "git checkout -"
@@ -308,9 +306,9 @@ module Homebrew
safe_system "git", "commit", "--no-edit", "--verbose",
"--message=#{formula.name} #{new_formula_version}#{devel_message}",
"--", formula.path
- safe_system "hub", "fork", "--no-remote"
- quiet_system "hub", "fork"
- remote = Utils.popen_read("hub fork 2>&1")[/fatal: remote (.+) already exists\./, 1]
+ remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1]
+ # repeat for hub 2.2 backwards compatibility:
+ remote = Utils.popen_read("hub fork 2>&1")[/remote:? (\S+)/, 1] if remote.to_s.empty?
odie "cannot get remote from 'hub'!" if remote.to_s.empty?
safe_system "git", "push", "--set-upstream", remote, "#{branch}:#{branch}"
pr_message = <<-EOS.undent