Merge pull request #18155 from Homebrew/github-simplifications

utils/github: a few more simplifications
This commit is contained in:
Bo Anderson 2024-08-25 00:50:45 +01:00 committed by GitHub
commit 36a0e539e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -910,15 +910,17 @@ module GitHub
github_user = data.fetch("login")
# BrewTestBot can open as many PRs as it wants.
return false if github_user.casecmp("brewtestbot").zero?
return false if data.dig("pullRequests", "totalCount") < MAXIMUM_OPEN_PRS
return false if github_user.casecmp?("brewtestbot")
homebrew_prs_count += data.dig("pullRequests", "nodes").count do |node|
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
data.dig("pullRequests", "pageInfo")
pull_requests.fetch("pageInfo")
end
false