Merge pull request #6770 from dawidd6/fix-bumping

bump-formula-pr: fix forking logic
This commit is contained in:
Mike McQuaid 2019-11-24 08:28:09 +00:00 committed by GitHub
commit 99a8f15fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,7 +341,7 @@ module Homebrew
remote_url = Utils.popen_read("git remote get-url --push origin").chomp remote_url = Utils.popen_read("git remote get-url --push origin").chomp
username = formula.tap.user username = formula.tap.user
else else
remote_url, username = forked_repo_info(tap_full_name) remote_url, username = forked_repo_info(formula, tap_full_name, backup_file)
end end
safe_system "git", "fetch", "--unshallow", "origin" if shallow safe_system "git", "fetch", "--unshallow", "origin" if shallow
@ -380,14 +380,15 @@ module Homebrew
end end
end end
def forked_repo_info(tap_full_name) def forked_repo_info(formula, tap_full_name, backup_file)
begin
response = GitHub.create_fork(tap_full_name) response = GitHub.create_fork(tap_full_name)
# GitHub API responds immediately but fork takes a few seconds to be ready.
sleep 3
rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e
formula.path.atomic_write(backup_file) formula.path.atomic_write(backup_file)
odie "Unable to fork: #{e.message}!" odie "Unable to fork: #{e.message}!"
else end
# GitHub API responds immediately but fork takes a few seconds to be ready.
sleep 1 until GitHub.check_fork_exists(tap_full_name)
remote_url = if system("git", "config", "--local", "--get-regexp", "remote\..*\.url", "git@github.com:.*") remote_url = if system("git", "config", "--local", "--get-regexp", "remote\..*\.url", "git@github.com:.*")
response.fetch("ssh_url") response.fetch("ssh_url")
else else