From 43ec1fc38a421b1271de4e72e13c46be01eca7cf Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Sun, 25 Aug 2024 04:33:42 +0800 Subject: [PATCH] utils/github: a few more simplifications Follow-up to #18150. --- Library/Homebrew/utils/github.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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