Skip to content

Commit

Permalink
shared_audits: allow GitHub's IP not permitted error
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin committed Aug 25, 2023
1 parent 3c8b494 commit e2e14bb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Library/Homebrew/utils/shared_audits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ module SharedAudits

URL_TYPE_HOMEPAGE = "homepage URL"

GITHUB_IP_ALLOWLIST_ERROR = Regexp.new("Although you appear to have the correct authorization credentials, " \
"the `(.+)` organization has an IP allow list enabled, " \
"and your IP address is not permitted to access this resource").freeze

module_function

def github_repo_data(user, repo)
Expand All @@ -21,6 +25,8 @@ def github_repo_data(user, repo)
@github_repo_data["#{user}/#{repo}"]
rescue GitHub::API::HTTPNotFoundError
nil
rescue GitHub::API::AuthenticationFailedError => e
e.message.match?(GITHUB_IP_ALLOWLIST_ERROR) ? nil : raise
end

def github_release_data(user, repo, tag)
Expand All @@ -32,6 +38,8 @@ def github_release_data(user, repo, tag)
@github_release_data[id]
rescue GitHub::API::HTTPNotFoundError
nil
rescue GitHub::API::AuthenticationFailedError => e
e.message.match?(GITHUB_IP_ALLOWLIST_ERROR) ? nil : raise
end

def github_release(user, repo, tag, formula: nil, cask: nil)
Expand Down

0 comments on commit e2e14bb

Please sign in to comment.