Merge pull request #11739 from Logicer16/dont-ask-for-a-PAT-if-one-already-exists

GitHub/API: Don't ask for a PAT if one already exists
This commit is contained in:
Mike McQuaid 2021-07-20 10:48:06 +01:00 committed by GitHub
commit 41d62e9084
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,7 +21,7 @@ module GitHub
#{ALL_SCOPES_URL}
#{Utils::Shell.set_variable_in_profile("HOMEBREW_GITHUB_API_TOKEN", "your_token_here")}
EOS
GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|ghp_\w{36,251})$/.freeze
GITHUB_PERSONAL_ACCESS_TOKEN_REGEX = /^(?:[a-f0-9]{40}|gh[po]_\w{36,251})$/.freeze
# Helper functions to access the GitHub API.
#
@ -48,10 +48,10 @@ module GitHub
class RateLimitExceededError < Error
def initialize(reset, github_message)
@github_message = github_message
new_pat_message = ", or:\n#{CREATE_GITHUB_PAT_MESSAGE}" if API.credentials.blank?
super <<~EOS
GitHub API Error: #{github_message}
Try again in #{pretty_ratelimit_reset(reset)}, or:
#{CREATE_GITHUB_PAT_MESSAGE}
Try again in #{pretty_ratelimit_reset(reset)}#{new_pat_message}
EOS
end