169 Commits

Author SHA1 Message Date
Bo Anderson
3e75b165ae
utils/github: rewrite get_workflow_run using GraphQL 2022-04-11 20:35:03 +01:00
Issy Long
84632598a0
utils/github: Add a branch_exists? method
- I wrote this as part of
  https://github.com/issyl0/homebrew-maintenance-utils/blob/main/cmd/find-invalid-head-branches.rb,
  as I needed to check if a branch exists on a repo, and thought I'd properly add
  it in case it's useful to others.
2022-03-05 21:29:19 +00:00
Rylan Polster
2e6b6ab3a2
Fix style 2021-12-24 21:15:21 -05:00
Bob Lail
31a831ae11 Bypass searching for open Issues when failing to install a formula without a tap
Given a formula with a broken build, if you install it locally with `brew install path/to/formula.rb`, when the build fails, Homebrew will attempt to [search for open issues on the tap](073c4177b5/Library/Homebrew/exceptions.rb (L489)); but in this case `formula.tap` is `nil` and `tap.full_name` would raise a `NoMethodError` yielding this output:

```
$ brew install ./erg.rb
Error: Failed to load cask: ./erg.rb
Cask 'erg' is unreadable: wrong constant name #<Class:0x00007fd89b246cd0>
Warning: Treating ./erg.rb as a formula.
==> Downloading https://github.com/square/erg/archive/v1.1.1.tar.gz
Already downloaded: /Users/lail/Library/Caches/Homebrew/downloads/54e3fce84302901d76d50b53aa7fe760cfcf81c9842a232d6b29e771de6ec9c5--erg-1.1.1.tar.gz
Warning: Cannot verify integrity of '54e3fce84302901d76d50b53aa7fe760cfcf81c9842a232d6b29e771de6ec9c5--erg-1.1.1.tar.gz'.
No checksum was provided for this resource.
For your reference, the checksum is:
  sha256 "8dbcff3dfd67b8f6e8f2dfd4f57cf818ce0cd6ce4b52566611e698fc8778507f"
==> go get github.com/square/erg
Last 15 lines from /Users/lail/Library/Logs/Homebrew/erg/01.go:
2021-12-02 16:45:31 +0000

go
get
github.com/square/erg

go: downloading github.com/square/erg v1.2.1
go: downloading vbom.ml/util v0.0.3
go: downloading vbom.ml/util/sortorder v1.0.2
go: downloading github.com/square/grange v0.0.0-20201015231752-48d66acdd125
go: downloading github.com/deckarep/golang-set v0.0.0-20170202203032-fc8930a5e645
go: downloading github.com/fvbommel/sortorder v1.0.1
go: downloading github.com/orcaman/concurrent-map v0.0.0-20160823150647-8bf1e9bacbf6
github.com/square/erg imports
	vbom.ml/util/sortorder: cannot find module providing package vbom.ml/util/sortorder

Do not report this issue to Homebrew/brew or Homebrew/core!

/usr/local/Homebrew/Library/Homebrew/utils/github.rb:64:in `issues_for_formula': undefined method `full_name' for nil:NilClass (NoMethodError)
	from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:489:in `fetch_issues'
	from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:485:in `issues'
	from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:539:in `dump'
	from /usr/local/Homebrew/Library/Homebrew/brew.rb:155:in `rescue in <main>'
	from /usr/local/Homebrew/Library/Homebrew/brew.rb:143:in `<main>'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2306:in `block in system': Failed executing: go get github.com/square/erg (BuildError)
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:2242:in `open'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:2242:in `system'
	from /Users/lail/Code/homebrew-formulas/erg.rb:13:in `install'
	from /usr/local/Homebrew/Library/Homebrew/build.rb:172:in `block (3 levels) in install'
	from /usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
	from /usr/local/Homebrew/Library/Homebrew/build.rb:134:in `block (2 levels) in install'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:1297:in `block in brew'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:2472:in `block (2 levels) in stage'
	from /usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:2471:in `block in stage'
	from /usr/local/Homebrew/Library/Homebrew/resource.rb:126:in `block (2 levels) in unpack'
	from /usr/local/Homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
	from /usr/local/Homebrew/Library/Homebrew/download_strategy.rb:115:in `chdir'
	from /usr/local/Homebrew/Library/Homebrew/download_strategy.rb:102:in `stage'
	from /usr/local/Homebrew/Library/Homebrew/resource.rb:122:in `block in unpack'
	from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
	from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
	from /usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `run'
	from /usr/local/Homebrew/Library/Homebrew/resource.rb:208:in `mktemp'
	from /usr/local/Homebrew/Library/Homebrew/resource.rb:121:in `unpack'
	from /usr/local/Homebrew/Library/Homebrew/resource.rb:96:in `stage'
	from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/forwardable.rb:230:in `stage'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:2451:in `stage'
	from /usr/local/Homebrew/Library/Homebrew/formula.rb:1290:in `brew'
	from /usr/local/Homebrew/Library/Homebrew/build.rb:129:in `block in install'
	from /usr/local/Homebrew/Library/Homebrew/utils.rb:588:in `with_env'
	from /usr/local/Homebrew/Library/Homebrew/build.rb:124:in `install'
	from /usr/local/Homebrew/Library/Homebrew/build.rb:224:in `<main>'
```
2021-12-02 10:56:44 -06:00
Caleb Xu
333f44f84e
github: use system_command when pushing bump PR 2021-11-10 12:42:14 -05:00
Bevan Kay
55d9e88a14
Mirror --write-only behaviour to cask, fix incorrect arg reference 2021-10-20 22:40:08 +11:00
Rylan Polster
4f1bbf003a
Use GitHub API to generate release notes 2021-10-05 14:43:17 -04:00
Maxim Belkin
370ef0ac1e
Fix Homebrew style issue
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-06-22 09:22:36 -05:00
Maxim Belkin
e967fffdfb
Apply Mike's suggestions
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-06-22 09:16:08 -05:00
Maxim Belkin
b29ec8cf65
utils/github.rb: fix dry-run message 2021-06-21 13:37:49 -05:00
Maxim Belkin
514271010a
Merge pull request #11556
github.rb: correct one dry-run message
2021-06-18 16:02:22 -05:00
Maxim Belkin
d533017d38 github.rb: correct one dry-run message 2021-06-17 19:32:10 +00:00
Mike McQuaid
30a65342e8
Deprecate, disable, delete code for Homebrew 3.2.0
Do the usual deprecation, disable, delete dance for Homebrew 3.2.0.
2021-06-17 11:34:32 +01:00
hyuraku
90c02f7b5a change https://api.github.com to API_URL 2021-06-02 21:13:53 +09:00
Dawid Dziurla
63be66408e
bump-formula-pr: add --fork-org flag 2021-04-17 09:53:15 +02:00
Mike McQuaid
d73351251c
Deprecate, disable, delete code for next major/minor version.
Do the usual dance for bumping our major/minor version.
2021-04-09 09:30:36 +01:00
Rylan Polster
4e61f61a20
utils/github: handle non-standard tap remotes 2021-03-21 12:35:45 -04:00
Bo Anderson
20ff68a425
Fix brew style. 2021-03-17 20:45:44 +00:00
nandahkrishna
7b0352f167
utils/github/api: simplify pagination 2021-03-11 14:50:19 +05:30
hyuraku
178ae750b9 utils/github: set default args to search_code 2021-02-26 21:31:30 +09:00
nandahkrishna
f7c8810214
utils/github/api: remove 'api' from method names 2021-02-17 23:47:05 +05:30
nandahkrishna
6d948bf6ab
utils/github: add wrapper for GitHub API method 2021-02-17 23:04:15 +05:30
nandahkrishna
56e0c3d9e8
Update GitHub API usage 2021-02-15 22:38:27 +05:30
nandahkrishna
9d8a5827a3
utils/github: split module 2021-02-15 21:08:10 +05:30
nandahkrishna
15f936a22a
dev-cmd/update-maintainers: implement suggestions from code review 2021-02-08 23:33:26 +05:30
nandahkrishna
6026c7c74d
brew update-maintainers: dev-cmd to update maintainers in README 2021-02-08 23:33:25 +05:30
Marcus Maxwell
f1ef1afd21
Add workflow scope to github.rb 2021-02-08 12:30:19 +00:00
Issy Long
f71ea65ee0
utils/github: Say "macOS keychain" in MissingAuthenticationError
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2021-02-05 13:52:32 +00:00
Issy Long
9394fe2b52
utils/github: Use constant everywhere for "create a PAT" message
- This way if we ever change this messaging, we only have to do so once.
2021-02-05 12:45:11 +00:00
Issy Long
ccb6d5e834
utils/github: Handle users not having any GitHub credentials
- When running `brew request-bottle`, users who don't have credentials
  in the macOS keychain (ie, Linux users) or `HOMEBREW_GITHUB_API_TOKEN`
  receive "Error: Not Found" from the GitHub API returning a 404.
- This is cryptic and confusing for newcomers to Linux maintenance, and
  potentially confusing to other folks using `open_api` where
  credentials are expected yet unset.
- This adds a new `MissingAuthenticationError` to handle the case where
  the GitHub API returns 404 and there are no creds yet API scopes are
  required.

Before:

```
issyl0@sky:/home/linuxbrew/.linuxbrew/Homebrew$ brew request-bottle hello
==> Dispatching request to Homebrew/linuxbrew-core for hello
Error: Not Found
```

After:

```
issyl0@sky:/home/linuxbrew/.linuxbrew/Homebrew$ brew request-bottle hello
==> Dispatching request to Homebrew/linuxbrew-core for hello
Error: No GitHub credentials found in Keychain or environment.
Create a GitHub personal access token:
    https://github.com/settings/tokens/new?scopes=gist,public_repo&description=Homebrew
  echo 'export HOMEBREW_GITHUB_API_TOKEN=your_token_here' >> ~/.profile
```
2021-02-05 12:44:46 +00:00
nandahkrishna
f15681ccd9
utils/github: fix false positive API credential error 2021-02-03 01:37:57 +05:30
Seeker
cded62333e bump-formula-pr: improvements 2021-01-24 11:23:43 -08:00
Rylan Polster
be02591cb6
Add brew release command 2021-01-21 18:29:43 -05:00
Seeker
f113f78ae2
Merge pull request #10283 from SeekingMeaning/github-util-cleanup
utils/github: cleanup
2021-01-11 16:21:19 -08:00
Seeker
b29c27b9a8
Merge pull request #10251 from SeekingMeaning/bump-pr-match
bump-*-pr: check existing PRs for exact file match
2021-01-11 08:40:47 -08:00
Seeker
86a7895115 utils/github: cleanup 2021-01-10 10:42:17 -08:00
Seeker
2901d2058a bump-*-pr: check for valid tap 2021-01-08 11:42:37 -08:00
Seeker
4886b3b138 github: check token scopes even if authorized 2021-01-07 17:47:08 -08:00
Seeker
1395259ad6 bump-*-pr: check existing PRs for exact file match 2021-01-07 09:15:42 -08:00
hyuraku
0b574eff90 search: add two options 2020-12-23 23:06:02 +09:00
Mike McQuaid
74fb058c7e
More deprecations
More deprecations, disabling and removal for Homebrew 2.7.0.
2020-12-18 14:17:37 +00:00
Mike McQuaid
3f2afc0eb2
utils/github: tweak search_code style.
As suggested by reitermarkus in
https://github.com/Homebrew/brew/pull/10055#discussion_r545829663
2020-12-18 13:47:57 +00:00
Mike McQuaid
48c0c673f8
Fix GitHub search behaviour change
Handle the case where paths are now returned with preceding `/`.
2020-12-18 13:21:06 +00:00
Jonathan Chang
09c3058618 Remove basic authentication support for GitHub.
Since we (and GitHub) no longer support password authentication
using non-token passwords, always set the Authorization header,
rather than needlessly checking for a (possibly incorrect) username.
2020-12-17 23:09:22 +11:00
Markus Reiter
b57a448f2a Add bump-unversioned-casks command. 2020-12-07 23:03:47 +01:00
Jonathan Chang
92d3eda914 git_extensions: move origin_branch from utils/git 2020-12-06 14:33:23 +11:00
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00
Mike McQuaid
db33c9a2a0
Merge pull request #9209 from MikeMcQuaid/deprecations
Deprecations for Homebrew 2.6.0
2020-11-25 08:49:52 +00:00
Mike McQuaid
d496f5c121
Deprecations for Homebrew 2.6.0
Do the usual deprecate/disable dance for the Homebrew 2.6.0 release.

Not to be merged until the next release will definitely be 2.6.0.
2020-11-24 16:44:02 +00:00
Michka Popoff
1fc3d22ab4 pr-pull: allow to pull from multiple workflows
and allow to skip missing workflows

Can be used like this:
brew pr-pull --workflows=tests.yml,wheezy_tests.yml --ignore-missing-artifacts=wheezy_tests.yml PRNUMBER
2020-11-24 15:46:44 +01:00