240 Commits

Author SHA1 Message Date
Mike McQuaid
c13700af00
Use repository consistently instead of repo
The documentation linting job doesn't like `repo` so let's fix this
globally rather than naming it differently in documentation and code.
2024-06-10 09:31:53 +01:00
Issy Long
a23dad737f
Fix constructing search query strings with date ranges
- Both `from` and `to` are now separate keyword arguments
  in a bunch of places, not part of `args`.
- When we switched this around, we didn't realize this
  method needed updating to correctly construct the time
  range query.
- This led to further inaccurate counts in `brew contributions`
  for reviews, since `from` and `to` are not valid search qualifiers
  for the GitHub PR search APIs.
2024-06-02 14:31:18 +01:00
Issy Long
808cfda92d
dev-cmd/contributions: Fix the date range behaviour
- This was broken (I did have a commit SHA for the breakage but I can't find it now) since `from` and `args.from` are different variables (one can be nil, the other has a default value).
- So it was reporting very high counts because, despite the message, the `from` restriction was not being passed to `count_repo_commits`.
2024-05-28 13:58:41 +01:00
Patrick Linnane
8ec44f279b
github.rb: fix grammar
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-05-13 14:57:08 -07:00
Patrick Linnane
992b50a413
various: fix minor typos
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-05-13 14:30:06 -07:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Ruoyu Zhong
84abc628aa
utils/github: paginate artifact API result
There can be too many artifacts in a workflow run to fit in a single API
response, so we need to paginate the result.
2024-04-24 04:20:02 +08:00
Ruoyu Zhong
9ad60fe437
utils/github: avoid returning artifacts with the same name 2024-04-17 07:35:40 +08:00
Ruoyu Zhong
dd92ad8e1b
Update default artifact pattern to avoid migration problems 2024-04-17 06:15:14 +08:00
Ruoyu Zhong
0df71ea6a3
utils/github: support globbing artifacts 2024-04-17 03:34:42 +08:00
Mike McQuaid
b3bf91acec
utils/github: fix tap logic.
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-03-28 12:30:01 +00:00
Mike McQuaid
fe16b14479
dev-cmd/bump*: limit the number of open PRs to 15.
Don't let users open more than 15 PRs at a time. We have other tooling
to nudge them to not do this but let's put it in the worst offenders:
the `bump*` commands.
2024-03-28 11:56:25 +00:00
Gibson Fahnestock
e11f797f25
bump-*-pr: handle HOMEBREW_NO_GITHUB_API=1 being set
We early return here
92a4311868/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 `<main>'
Rerun with `--verbose` to see the original backtrace
```
2024-03-25 11:11:01 +00:00
Bo Anderson
e6f64767c5
utils/github: fix variable scope 2024-03-16 03:25:44 +00:00
Bo Anderson
7b0c3d54f1
utils/github: use GraphQL PR searching 2024-03-15 21:27:05 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Kevin
4ea6a8ccbb Remove ability to skip the duplicate PR check in autobump
This simply removes the environment variable check. The code was disabled in core around two weeks ago in https://github.com/Homebrew/homebrew-core/pull/163023. We need this PR to land first as explained in https://github.com/Homebrew/actions/pull/506#issuecomment-1972489707 to unblock other PRs.
2024-02-29 20:47:28 -08:00
Issy Long
c2507fdc6d
formula_audit: Check the license(s) of the specific release
- Some repositories occasionally change their licenses. For example they
  release a version of the software with one license and then decide to change
  the license later.
- Now that `?ref=` is a parameter to the GitHub Repositories License API,
  we can use that in the license audit to check if the license of the specific
  release matches the one declared in the formula.
2024-02-27 16:53:54 +00:00
Bo Anderson
913c46d994
utils/github: support HOMEBREW_GITHUB_API_TOKEN with --no-fork 2024-02-26 23:43:58 +00:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Mike McQuaid
7df07b991b
dev-cmd/bump*: do not allow forcing multiple PRs.
If there are duplicate PRs: we shouldn't suggest and allow a trivial
override. Instead, they should be created manually.

An undocumented override exists for BrewTestBot to do autobumps.
2024-02-15 17:02:31 +00:00
Eric Knibbe
e63b1f4da5
docs: monospace suggested values 2024-02-04 15:42:26 +01:00
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