diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index c97b17997a..ca64c4741c 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -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