From e11f797f25d6b9f9b01f4cc4d83c9559c41b3d63 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Mon, 25 Mar 2024 08:50:52 +0000 Subject: [PATCH] bump-*-pr: handle HOMEBREW_NO_GITHUB_API=1 being set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We early return here https://github.com/homebrew/brew/blob/92a4311868322188478d7a90511ec0e8e6b0d7df/Library/Homebrew/utils/github/api.rb#L220 , but don't then handle that through the stack. Repro: ```console ❯ HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_GITHUB_API=1 brew bump-formula-pr --write-only --version 1.2.3 --no-audit jq Error: undefined method `[]' for nil:NilClass Do not report this issue until you've run `brew update` and tried again. Warning: Removed Sorbet lines from backtrace! /opt/homebrew/Library/Homebrew/utils/github.rb:565:in `block in fetch_pull_requests' /opt/homebrew/Library/Homebrew/utils/github/api.rb:334:in `paginate_graphql' /opt/homebrew/Library/Homebrew/utils/github.rb:564:in `fetch_pull_requests' /opt/homebrew/Library/Homebrew/utils/github.rb:628:in `check_for_duplicate_pull_requests' /opt/homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:456:in `check_open_pull_requests' /opt/homebrew/Library/Homebrew/dev-cmd/bump-formula-pr.rb:135:in `run' /opt/homebrew/Library/Homebrew/brew.rb:89:in `
' Rerun with `--verbose` to see the original backtrace ``` --- Library/Homebrew/utils/github.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 795cb17e8a..5117f58b12 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -521,6 +521,8 @@ module GitHub .returns(T::Array[T::Hash[String, T.untyped]]) } def self.fetch_pull_requests(name, tap_remote_repo, state: nil, version: nil) + return [] if Homebrew::EnvConfig.no_github_api? + regex = pull_request_title_regex(name, version) query = "is:pr #{name} #{version}".strip