- The usage of this in `brew contributions` wasn't correct for a user
with 5 authored commits to homebrew/cask that had been committed by
other people, the numbers would turn out as 5 authored, 5 committed.
- I decided to do this properly by getting the SHAs for author and
committer and determine the differences between the two arrays.
This also accounts for when authored commits are 0, or committed
commits, or both.
- Add tests, because I don't want to fix this a third time!
- The GitHub list commits API now supports this filtering
(https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits--parameters),
because I wrote it. :-)
- Authoring a commit and committing a commit are two separate concepts: author
is the person who wrote the code and, in old parlance, the committer is the
person who applied the patch (remember when we sent patches to mailing lists?).
- In practice for us in Homebrew, this occurs when we make a change in GitHub's
web editor, or, more obviously, when BrewTestBot pushes `homebrew-core`
commits from users (then, `BrewTestBot` is the `committer`).
- Now `brew contributions --from=2023-02-23 --to=2023-02-26` works to limit the
results for reviews. I forgot this in the original implementation, again,
ugh.
- The search APIs don't have that high a rate limit but we shouldn't need to
worry about that too much because, to get counts, the JSON response comes
with a `total_count` number.
- Functionally it doesn't matter that the URL will have an `&` at the
end if `additional_query_params` is `nil`, because it doesn't affect
the URL at all.
- These are arbitrary length limits that had a load of disables in code.
- The limits were only increasing over time rather than decreasing.
- Fixing the problematic code to be shorter would take a long time for
questionable gain since the problem has been around so long.
- Using `git log` was brittle with name changes and email address changes for
contributors over the years unless we made a Git `mailmap` file which brings
with it its own updatedness overhead.
- Let's use the GitHub commits API (importantly _not_ the search API) so that
we can give it a username and it will return contributions associated with
every email address on that user's account:
https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits--parameters.
- This is quite significantly slower, but it's worth it for correctness
especially when we get to all maintainers' contributions (in a separate PR).
- The commits API does not (yet?) support trailers or commit "committer"s, just
authors.
- We're not going to make the really long things be any shorter any time soon.
- The instructions in issue 14685 say, pragmatically, "disable all the rubocop
rules we're never going to realistically fix e.g. Metrics/ClassLength". But
that felt like a slippery slope to more _really_ long modules/classes/blocks,
and the limits are here for a reason.
Currently we only check for closed PRs in
`bump-cask-pr`. This adds that check to `bump`
and `bump-formula-pr`. The idea is that this
check can warn users about already updated
packages or those that can't be updated
easily and should be updated manually instead.
This change will prevent us having to run some long running builds
multiple times and to rely on luck to get things merged without conflicts.
The check takes less than 30 secondes on my local setup.
Follow up adter #13124
I made the choice to convert the pr variable to an integer
at the very end and adjust the tests.
It would be maybe more consistent to work with an integer
everywhere, but this needs a more careful analysis and we
are in a hurry to fix the homberew-core upload CI
Fixes:
2022-04-11T20:19:34.1395885Z [31mError:[0m : Variable $pr of type Int! was provided invalid value
2022-04-11T20:19:34.1398279Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github/api.rb:261:in `open_graphql'
2022-04-11T20:19:34.1399774Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/github.rb:310:in `get_workflow_run'
2022-04-11T20:19:34.1403699Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:418:in `block (4 levels) in pr_pull'
2022-04-11T20:19:34.1405233Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `each'
2022-04-11T20:19:34.1406723Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:417:in `block (3 levels) in pr_pull'
2022-04-11T20:19:34.1408112Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `chdir'
2022-04-11T20:19:34.1408986Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/fileutils.rb:128:in `cd'
2022-04-11T20:19:34.1409813Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:400:in `block (2 levels) in pr_pull'
2022-04-11T20:19:34.1410671Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8/lib/ruby/2.6.0/tmpdir.rb:93:in `mktmpdir'
2022-04-11T20:19:34.1411495Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:399:in `block in pr_pull'
2022-04-11T20:19:34.1412250Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `each'
2022-04-11T20:19:34.1413056Z /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/pr-pull.rb:388:in `pr_pull'
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>'
```