Merge pull request #6776 from maxim-belkin/dawid66++
GitHub Actions: get username if we don't have it
This commit is contained in:
commit
2e382cdbdf
@ -381,14 +381,13 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def forked_repo_info(formula, tap_full_name, backup_file)
|
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)
|
rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e
|
||||||
# GitHub API responds immediately but fork takes a few seconds to be ready.
|
formula.path.atomic_write(backup_file)
|
||||||
sleep 3
|
odie "Unable to fork: #{e.message}!"
|
||||||
rescue GitHub::AuthenticationFailedError, *GitHub.api_errors => e
|
else
|
||||||
formula.path.atomic_write(backup_file)
|
# GitHub API responds immediately but fork takes a few seconds to be ready.
|
||||||
odie "Unable to fork: #{e.message}!"
|
sleep 1 until GitHub.check_fork_exists(tap_full_name)
|
||||||
end
|
|
||||||
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
|
||||||
|
|||||||
@ -341,9 +341,16 @@ module GitHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_fork_exists(repo)
|
def check_fork_exists(repo)
|
||||||
_, username = api_credentials
|
|
||||||
_, reponame = repo.split("/")
|
_, reponame = repo.split("/")
|
||||||
|
|
||||||
|
case api_credentials_type
|
||||||
|
when :keychain
|
||||||
|
_, username = api_credentials
|
||||||
|
when :environment
|
||||||
|
username = open_api(url_to("user")) { |json| json["login"] }
|
||||||
|
end
|
||||||
json = open_api(url_to("repos", username, reponame))
|
json = open_api(url_to("repos", username, reponame))
|
||||||
|
|
||||||
return false if json["message"] == "Not Found"
|
return false if json["message"] == "Not Found"
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user