218 Commits

Author SHA1 Message Date
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Mike McQuaid
8c1c0c5a22
utils/github: fully scope curl usage.
Fixes #15965
2023-09-05 17:07:59 -04:00
Mike McQuaid
d357607b2c
dev-cmd/contributions: usability/performance improvements.
- more sensible/performant defaults: default to primary repositories
  only for the last year rather than all repositories forever
- allow specifying more than one user at a time
- output the breakdown of contributions without needing `--csv`
- add a space before the `--csv` output
- consolidate some code
- avoid counting authored commits twice, to improve performance
- retry failed GitHub API calls (this happens often when querying all
  maintainers)
- stop counting after we find 1000 commits for a given user to avoid
  excessive API queries/pagination
2023-08-30 15:08:50 +01:00
Alexander Bayandin
45378f35e2 get_repo_license: ignore ip allowlist error 2023-08-26 17:16:43 +01:00
Issy Long
b9d8fd4f79
Enable issues_for_formula to show only issues, only PRs, or both
- This change is useful for the "these issues are also open for this
  build failure" exception. Hopefully there'll be less noise on PRs with
  people encouraging us to fix things faster if we don't link them to
  WIP PRs (or any PRs at all).
- Fixes https://github.com/Homebrew/brew/issues/ 15608.
2023-07-08 22:15:58 +01:00
Carlo Cabrera
fb73f074b6
utils/github: clarify comment
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-06-02 11:52:11 +08:00
Carlo Cabrera
0376c6c5c1
utils/github: use Pulls API to check open pull requests on CI
We currently use the search API to check for duplicate pull requests,
but this is not very reliable. Our `autobump.yml` workflow routinely
opens duplicate pull requests [1] because the search API often returns
incorrect results.

We can make this more reliable by using the Pulls API instead.
Unfortunately, querying the Pulls API is very slow (~10s vs less than a
second for the search API), so let's limit its usage to calls made
inside CI, which should help @BrewTestBot avoid opening duplicate PRs.
(Most recent dupes were authored by @BrewTestBot.)

[1] https://github.com/Homebrew/homebrew-core/pulls?q=is%3Apr+author%3ABrewTestBot+is%3Aunmerged+in%3Acomments+Duplicate
2023-05-10 13:08:32 +08:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Razvan Azamfirei
a2b80e4ec2
fix origin_branch_name 2023-04-17 09:57:06 -04:00
Bo Anderson
3697825784
search: remove remote searching 2023-04-12 13:16:19 +01:00
Douglas Eichelberger
c5ffec1a11 Enable types in dev-cmd, etc. 2023-04-04 22:23:46 -07:00
Dawid Dziurla
5e1253ba0d
github: set maintainer_can_modify for PR creation 2023-03-31 11:29:05 +02:00
Issy Long
61dc026fcc
rubocop: Remove the final Naming/MethodParameterName exceptions: pr
- Core RuboCop didn't want this shortening upstreamed, but that's OK!
2023-03-24 00:29:42 +00:00
Douglas Eichelberger
827fc87cde Enable more typing 2023-03-15 14:29:15 -07:00
Issy Long
edeefebf61
utils/github: Fix double counting of author/committer numbers
- 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!
2023-03-05 14:41:04 +00:00
Issy Long
9250a6705e
dev-cmd/contributions: Count the number of commits a user committed
- 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`).
2023-03-01 23:38:49 +00:00
Mike McQuaid
6db7732fa3
Merge pull request #14821 from issyl0/support-date-ranges-in-pr-reviews-query
dev-cmd/contributions: Support date ranges in PR reviews query
2023-02-28 00:06:41 +00:00
Issy Long
a2d31faa72
dev-cmd/contributions: Support date ranges in PR reviews query
- 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.
2023-02-26 23:34:53 +00:00
Issy Long
214e2102c3
utils/github: Remove unnecessary .delete_prefix("/")
- This workaround was originally added in 2020. I have confirmed with
  https://api.github.com/search/code?q=brew+language%3Aruby+org:Homebrew that
  the `path` string no longer has a leading `/`.
2023-02-26 15:27:02 +00:00
Issy Long
550599d03b
utils/github: Switch check_fork_exists to fork_exists?
- It's Ruby style convention that methods that return only booleans end with a
  question mark.
2023-02-26 15:26:07 +00:00
Issy Long
591afa8ee0
utils/github: Appease brew style line length 2023-02-25 22:27:48 +00:00
Issy Long
99d2bb9a53
utils/github: Use search_results_items method for code search 2023-02-25 22:01:12 +00:00
Issy Long
8c75eab88a
dev-cmd/contributions: Count PR reviews since they're super important
- 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.
2023-02-25 19:10:17 +00:00
Issy Long
28a2a6ea43
utils/github: Add date filtering to the commit author API query
- I missed this off the original implementation - oops. This gives parity with
  the `git log` implementation.
2023-02-22 23:01:38 +00:00
Issy Long
93ce211ebd
Merge pull request #14737 from issyl0/api-commits-for-person
dev-cmd/contributions: Use GitHub APIs for commit author info
2023-02-22 14:12:16 +00:00
Issy Long
c9e6b81b4b
utils/github: API.paginate_rest handles extra query params
- 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.
2023-02-21 11:06:30 +00:00
Issy Long
298bb65dfb
rubocop: Entirely disable Metrics cops
- 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.
2023-02-21 00:34:17 +00:00
Issy Long
d3827b12f2
dev-cmd/contributions: Use GitHub APIs for commit author info
- 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.
2023-02-20 23:24:54 +00:00
Issy Long
f8654bd363
rubocop: In-line disables of Metrics/{Module,Block,Class}Length
- 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.
2023-02-19 16:33:23 +00:00
anatawa12
cd045b53e8
fix(utils/github): failure with fine-granted api tokens 2023-02-11 00:06:28 +09:00
Michael Cho
3beca4f691
utils/github: get artifact from last run 2023-02-08 18:22:58 -08:00
apainintheneck
a8ee2b7746 Add closed PR check to bump cmds
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.
2023-01-20 18:46:07 -08:00
Mike McQuaid
77c0d38c35
brew style --fix 2022-12-13 11:37:06 +00:00
hyuraku
6423c27e8b change the condition on GitHub.multiple_short_commits_exist? 2022-11-08 21:02:11 +09:00
hyuraku
5522cd106f use url_to instead of url string 2022-11-08 18:54:18 +09:00
hyuraku
903cac3651 refactor GitHub.multiple_short_commits_exist? 2022-11-07 23:44:42 +09:00
hyuraku
3e092e5e90 refactor option style 2022-11-07 23:12:07 +09:00
hyuraku
3f3a0b5469 move two methods from download_storategy to utils/github 2022-11-06 18:12:43 +09:00
Mike McQuaid
344d47accc
sponsors-maintainers-man-completions: various fixes.
- fix name
- use correct command
2022-09-08 12:19:13 +01:00
Mike McQuaid
bc295f7947
update-sponsors: don't require admin token.
Instead, use a different API to query these with a lower scope.

This should be usable by GitHub Actions.
2022-09-07 16:49:41 +01:00
Bo Anderson
04f6f53b58
dev-cmd/pr-pull: avoid expensive search API calls 2022-09-03 21:19:37 +01:00
Michka Popoff
756c2b2c52
github/pr-pull: fix/improve parameters
Fixes #13634
2022-08-03 14:13:50 +02:00
Michka Popoff
374c3985d6
pr-pull: check for conflicts with long running builds
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.
2022-08-01 23:34:06 +02:00
Mike McQuaid
22d6af1258
Manual brew style fixes. 2022-06-30 08:56:21 +01:00
Bo Anderson
580fb58f62
utils/github: take last artifact rather than first 2022-05-24 23:31:29 +01:00
Bo Anderson
17ee0eefb8
utils/github: fix errors with check suites without workflow runs 2022-04-12 13:42:14 +01:00
Michka Popoff
a5c29fff2d
utils/github.rb: convert pr to integer
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'
2022-04-11 22:38:42 +02:00
Bo Anderson
3e75b165ae
utils/github: rewrite get_workflow_run using GraphQL 2022-04-11 20:35:03 +01:00