Skip to content

Commit

Permalink
Merge pull request #18778 from elijaholmos/too-many-prs-saml-patch
Browse files Browse the repository at this point in the history
fix: `too_many_open_prs()` fails without SSO access
  • Loading branch information
MikeMcQuaid authored Nov 18, 2024
2 parents 7de8d2d + ba4dfb2 commit a12a215
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -924,22 +924,27 @@ def self.too_many_open_prs?(tap)

homebrew_prs_count = 0

API.paginate_graphql(query) do |result|
data = result.fetch("viewer")
github_user = data.fetch("login")
begin
API.paginate_graphql(query) do |result|
data = result.fetch("viewer")
github_user = data.fetch("login")

# BrewTestBot can open as many PRs as it wants.
return false if github_user.casecmp?("brewtestbot")
# BrewTestBot can open as many PRs as it wants.
return false if github_user.casecmp?("brewtestbot")

pull_requests = data.fetch("pullRequests")
return false if pull_requests.fetch("totalCount") < MAXIMUM_OPEN_PRS
pull_requests = data.fetch("pullRequests")
return false if pull_requests.fetch("totalCount") < MAXIMUM_OPEN_PRS

homebrew_prs_count += pull_requests.fetch("nodes").count do |node|
node.dig("baseRepository", "owner", "login").casecmp?("homebrew")
end
return true if homebrew_prs_count >= MAXIMUM_OPEN_PRS
homebrew_prs_count += pull_requests.fetch("nodes").count do |node|
node.dig("baseRepository", "owner", "login").casecmp?("homebrew")
end
return true if homebrew_prs_count >= MAXIMUM_OPEN_PRS

pull_requests.fetch("pageInfo")
pull_requests.fetch("pageInfo")
end
rescue => e
# Ignore SAML access errors (https://github.com/Homebrew/brew/issues/18610)
raise unless e.message.include?("Resource protected by organization SAML enforcement")
end

false
Expand Down

0 comments on commit a12a215

Please sign in to comment.