From 2735663dc3eabec3056c0b37fbf9b59c3cae4d41 Mon Sep 17 00:00:00 2001 From: Maxim Belkin Date: Mon, 25 Nov 2019 16:43:29 -0600 Subject: [PATCH] GitHub Actions: get username if we don't have it --- Library/Homebrew/utils/github.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 2e6695f4f4..195dbaa54b 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -341,9 +341,16 @@ module GitHub end def check_fork_exists(repo) - _, username = api_credentials _, 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)) + return false if json["message"] == "Not Found" true