Skip to content

Commit

Permalink
bump-*-pr: handle HOMEBREW_NO_GITHUB_API=1 being set
Browse files Browse the repository at this point in the history
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 --tag 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 `<main>'
Rerun with `--verbose` to see the original backtrace
```
  • Loading branch information
gibfahn committed Mar 25, 2024
1 parent 92a4311 commit ab98bfd
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Library/Homebrew/utils/github.rb
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ def self.fetch_pull_requests(name, tap_remote_repo, state: nil, version: nil)

pull_requests = []
API.paginate_graphql(graphql_query, variables:) do |result|
return [] if result.nil?
data = result["search"]
pull_requests.concat(data["nodes"].select { |pr| regex.match?(pr["title"]) })
data["pageInfo"]
Expand Down

0 comments on commit ab98bfd

Please sign in to comment.