Use rescue
instead of yield
This commit is contained in:
parent
d0c7c4fd71
commit
ffcf06867a
@ -362,8 +362,11 @@ module Homebrew
|
||||
remote_url = Utils.popen_read("git remote get-url --push origin").chomp
|
||||
username = formula.tap.user
|
||||
else
|
||||
remote_url, username = GitHub.forked_repo_info!(tap_full_name) do
|
||||
begin
|
||||
remote_url, username = GitHub.forked_repo_info!(tap_full_name)
|
||||
rescue *GitHub.api_errors => e
|
||||
formula.path.atomic_write(old_contents)
|
||||
odie "Unable to fork: #{e.message}!"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -606,10 +606,6 @@ module GitHub
|
||||
|
||||
def forked_repo_info!(tap_full_name)
|
||||
response = GitHub.create_fork(tap_full_name)
|
||||
rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e
|
||||
yield
|
||||
odie "Unable to fork: #{e.message}!"
|
||||
else
|
||||
# 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:.*")
|
||||
|
Loading…
x
Reference in New Issue
Block a user