Use rescue instead of yield

This commit is contained in:
Seeker 2020-08-18 22:53:46 -07:00
parent d0c7c4fd71
commit ffcf06867a
2 changed files with 4 additions and 5 deletions

View File

@ -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

View File

@ -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:.*")