Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: too_many_open_prs() fails without SSO access #18778

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

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")

Check warning on line 930 in Library/Homebrew/utils/github.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/github.rb#L928-L930

Added lines #L928 - L930 were not covered by tests

# 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")

Check warning on line 935 in Library/Homebrew/utils/github.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/github.rb#L935

Added line #L935 was not covered by tests
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")

Check warning on line 939 in Library/Homebrew/utils/github.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/github.rb#L938-L939

Added lines #L938 - L939 were not covered by tests
end
return true if homebrew_prs_count >= MAXIMUM_OPEN_PRS

pull_requests.fetch("pageInfo")
pull_requests.fetch("pageInfo")

Check warning on line 943 in Library/Homebrew/utils/github.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/github.rb#L943

Added line #L943 was not covered by tests
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
Loading