bump-formula-pr: enable same-repo (no-fork) Pull Requests
This commit is contained in:
parent
eb019ee330
commit
620e96b929
@ -38,6 +38,8 @@ module Homebrew
|
||||
description: "Run `brew audit --strict` before opening the PR."
|
||||
switch "--no-browse",
|
||||
description: "Print the pull request URL instead of opening in a browser."
|
||||
switch "--no-fork",
|
||||
description: "Don't try to fork the repository."
|
||||
flag "--mirror=",
|
||||
description: "Use the specified <URL> as a mirror URL."
|
||||
flag "--version=",
|
||||
@ -324,7 +326,7 @@ module Homebrew
|
||||
changed_files += alias_rename if alias_rename.present?
|
||||
|
||||
if args.dry_run?
|
||||
ohai "try to fork repository with GitHub API"
|
||||
ohai "try to fork repository with GitHub API" unless args.no_fork?
|
||||
ohai "git fetch --unshallow origin" if shallow
|
||||
ohai "git add #{alias_rename.first} #{alias_rename.last}" if alias_rename.present?
|
||||
ohai "git checkout --no-track -b #{branch} #{origin_branch}"
|
||||
@ -335,12 +337,16 @@ module Homebrew
|
||||
ohai "create pull request with GitHub API"
|
||||
else
|
||||
|
||||
if args.no_fork?
|
||||
remote_url = Utils.popen_read("git remote get-url --push origin").chomp
|
||||
username = formula.tap.user
|
||||
else
|
||||
begin
|
||||
response = GitHub.create_fork(tap_full_name)
|
||||
response = GitHub.create_fork(formula.tap.full_name)
|
||||
# GitHub API responds immediately but fork takes a few seconds to be ready.
|
||||
sleep 3
|
||||
|
||||
if system("git", "config", "--get-regexp", "remote\..*\.url", "git@github.com:.*")
|
||||
if system("git", "config", "--local", "--get-regexp", "remote\..*\.url", "git@github.com:.*")
|
||||
remote_url = response.fetch("ssh_url")
|
||||
else
|
||||
remote_url = response.fetch("clone_url")
|
||||
@ -357,6 +363,7 @@ module Homebrew
|
||||
formula.path.atomic_write(backup_file) unless args.dry_run?
|
||||
odie "Unable to fork: #{e.message}!"
|
||||
end
|
||||
end
|
||||
|
||||
safe_system "git", "fetch", "--unshallow", "origin" if shallow
|
||||
safe_system "git", "add", *alias_rename if alias_rename.present?
|
||||
|
Loading…
x
Reference in New Issue
Block a user