aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd/bump-formula-pr.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/dev-cmd/bump-formula-pr.rb')
-rw-r--r--Library/Homebrew/dev-cmd/bump-formula-pr.rb33
1 files changed, 30 insertions, 3 deletions
diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
index fe7e6be3d..380bb464d 100644
--- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb
+++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb
@@ -29,6 +29,10 @@
#: If `--message=`<message> is passed, append <message> to the default PR
#: message.
#:
+#: If `--no-browse` is passed, don't pass the `--browse` argument to `hub`
+#: which opens the pull request URL in a browser. Instead, output it to the
+#: command line.
+#:
#: Note that this command cannot be used to transition a formula from a
#: URL-and-sha256 style specification into a tag-and-revision style
#: specification, nor vice versa. It must use whichever style specification
@@ -109,6 +113,21 @@ module Homebrew
end
def bump_formula_pr
+ # As this command is simplifying user run commands then let's just use a
+ # user path, too.
+ ENV["PATH"] = ENV["HOMEBREW_PATH"]
+
+ # Use the user's browser, too.
+ ENV["BROWSER"] = ENV["HOMEBREW_BROWSER"]
+
+ # Setup GitHub environment variables
+ %w[GITHUB_USER GITHUB_PASSWORD GITHUB_TOKEN].each do |env|
+ homebrew_env = ENV["HOMEBREW_#{env}"]
+ next unless homebrew_env
+ next if homebrew_env.empty?
+ ENV[env] = homebrew_env
+ end
+
formula = ARGV.formulae.first
if formula
@@ -293,13 +312,21 @@ module Homebrew
git_dir = Utils.popen_read("git rev-parse --git-dir").chomp
shallow = !git_dir.empty? && File.exist?("#{git_dir}/shallow")
+ hub_args = []
+ git_final_checkout_args = []
+ if ARGV.include?("--no-browse")
+ git_final_checkout_args << "--quiet"
+ else
+ hub_args << "--browse"
+ end
+
if ARGV.dry_run?
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 # 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 "hub pull-request #{hub_args.join(" ")} -m '#{formula.name} #{new_formula_version}#{devel_message}'"
ohai "git checkout -"
else
safe_system "git", "fetch", "--unshallow", "origin" if shallow
@@ -324,8 +351,8 @@ module Homebrew
#{user_message}
EOS
end
- safe_system "hub", "pull-request", "--browse", "-m", pr_message
- safe_system "git", "checkout", "-"
+ safe_system "hub", "pull-request", *hub_args, "-m", pr_message
+ safe_system "git", "checkout", *git_final_checkout_args, "-"
end
end
end