1738 Commits

Author SHA1 Message Date
Carlo Cabrera
654a58237e
formula: make audit_result a kwarg in inreplace
This allows us to get rid of a RuboCop disable, and will make formulae
easier to read.
2024-09-01 05:05:13 +08:00
Sam Ford
24ac6967ba
Adjust typing around #check_pull_requests
`brew bump-formula-pr` is encountering a type error, as the inferred
return type of `GitHub#check_for_duplicate_pull_requests` doesn't
align with the explicit return type of `#check_pull_requests`:

```
Error: Return value: Expected type T.nilable(T::Array[String]), got
  type Module with value T::Private::Types::Void::VOID
Caller: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/dev-cmd/
  bump-formula-pr.rb:137
Definition: /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/
  dev-cmd/bump-formula-pr.rb:472 (Homebrew::DevCmd::BumpFormulaPr
  #check_pull_requests)
```

This addresses the issue by adding a type signature with a `void`
return type to `#check_for_duplicate_pull_requests` and setting the
return type of `#check_pull_requests` to `void` as well. The return
type from `#check_pull_requests` isn't used, so a `void` return type
is arguably a better reflection of the method's behavior. The
`#check_pull_requests` method in `BumpCaskPr` has a `void` return
type, so this change brings the `BumpFormulaPr` method in line.
2024-08-31 16:42:43 -04:00
Mike McQuaid
fe909c41b8
Improve duplicate pull request handling
- change the messaging depending on how confident we are that we're
  actually looking at duplicates i.e. we're not confident without a
  version number supplied
- similarly, just warn instead of failing with an error (and no
  override) if we're not confident that we're looking at duplicates
  because a version wasn't supplied
- change `bump-cask-pr` and `bump-formula-pr` to always check for all
  pull requests with the new version number (to allow failing on this)
  rather than only checking closed pull requests with a version number
- change `bump` to check for definite/maybe duplicate PRs and only
  exit if they are definitely duplicates
- cleanup some variable usage to DRY things up a bit
2024-08-30 14:21:42 +01:00
Carlo Cabrera
e3d295ae12
Merge pull request #18203 from Homebrew/sponsorships-error 2024-08-30 11:13:29 +08:00
Carlo Cabrera
ed589c0a19
Merge pull request #18202 from Homebrew/fix-sponsorships-query 2024-08-30 11:02:28 +08:00
Carlo Cabrera
c740bef176
utils/github: improve sponsorships error handling
Let's make sure we get the opportunity to print the errors if the query
response doesn't have the form we expected it to take.
2024-08-30 11:00:53 +08:00
Carlo Cabrera
5897ed80d9
utils/github: fix sponsorships GraphQL query
This fixes the failure in our sponsorships workflow.
2024-08-30 10:50:59 +08:00
Carlo Cabrera
cabbb0b8e3
Remove GraphQL debug output
Let's get this ready to go since we don't want to accidentally leak
private information.
2024-08-30 10:45:19 +08:00
Carlo Cabrera
7645484ac3
utils/github/api: add debug output for open_graphql
Our updating sponsors/maintainers/etc workflow is broken.

Let's add some debug output to help me fix it.
2024-08-30 10:15:56 +08:00
Michael Cho
06fc2247c7
Merge pull request #18178 from cho-m/github-tag
utils/shared_audits: GitHub urls can have '.' in repo and '/' in tag
2024-08-28 21:55:29 -04:00
Bo Anderson
6a0db5035f
Fix misuse of fork in sandbox causing crashes 2024-08-28 13:53:01 +01:00
Michael Cho
d1dc3b2206
utils/shared_audits: GitHub urls can have '.' in repo and '/' in tag 2024-08-27 11:39:50 -04:00
Mike McQuaid
81d26f8059
Merge pull request #18169 from cho-m/spdx-case-sensitive 2024-08-27 09:28:55 +01:00
Michael Cho
cccab0d9a9
utils/shared_audits: allow subgroups in gitlab url 2024-08-26 23:07:31 -04:00
Michael Cho
82fbbcc88b
utils/spdx: fix invalid SPDX syntax for symbols
Also use more common uppercase operators for backwards compatibility
2024-08-26 13:55:37 -04:00
Mike McQuaid
d58302ef6b
Merge pull request #18147 from Homebrew/shellcheck-helpers.sh 2024-08-26 09:17:24 +01:00
Carlo Cabrera
43ec1fc38a
utils/github: a few more simplifications
Follow-up to #18150.
2024-08-25 04:33:42 +08:00
Bo Anderson
0408c184ac
Merge pull request #18152 from Homebrew/more-paginate-graphql
utils/github: use `paginate_graphql` in `sponsorships`
2024-08-24 20:17:02 +01:00
Carlo Cabrera
4a7579c693
utils/github: use paginate_graphql in sponsorships
`sponsorships` has its own implementation of GraphQL pagination. We can
simplify this by using `paginate_graphql` instead.
2024-08-25 01:34:36 +08:00
Carlo Cabrera
03d9a3dda5
utils/github: use #fetch
Co-authored-by: Markus Reiter <me@reitermark.us>
2024-08-24 23:10:39 +08:00
Carlo Cabrera
f873835b97
utils/github: fix too_many_open_prs?
This doesn't count PRs from forks, so it only works correctly for
maintainers (and only if they use non-fork branches).

Let's fix that, and:
- simplify the logic by using `paginate_graphql`
- return early if it's impossible for them to have too many open PRs
2024-08-24 22:51:23 +08:00
Carlo Cabrera
ca0639998a
utils/helpers.sh: remove a shellcheck disable
I don't think we need this.
2024-08-24 08:54:01 +08:00
Bo Anderson
092dcdbeac
shared_audits: remove module_function 2024-08-23 03:34:48 +01:00
Bo Anderson
6db4ed2793
Replace some include Kernel usages with requires_ancestor 2024-08-20 19:10:14 +01:00
Mike McQuaid
954f24077e
Merge pull request #18094 from Homebrew/include-kernel 2024-08-20 09:08:43 +01:00
Bo Anderson
3627cca066
Remove some unnecessary include Kernel 2024-08-20 04:16:18 +01:00
Bo Anderson
561cc17a74
utils/gems: remove module_function 2024-08-20 03:57:23 +01:00
Rui Chen
1270eb37b1
formula_auditor: fix eol check
Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
2024-08-13 16:36:38 +08:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
6105728c31
Merge pull request #18004 from Homebrew/more-srb-strict 2024-08-12 14:22:00 +01:00
Issy Long
0355f07e0d
utils/shared_audits: Bump to Sorbet typed: strict 2024-08-10 16:43:37 +01:00
Issy Long
e9cb08f431
utils/service: Bump to Sorbet typed: strict 2024-08-10 16:43:37 +01:00
Issy Long
ef9520cd6c
utils/svn: Bump to Sorbet typed: strict 2024-08-10 12:59:51 +01:00
Issy Long
29a3ede4b1
utils/user: Bump to Sorbet typed: strict 2024-08-10 00:31:58 +01:00
Issy Long
058688f239
utils/link: Bump to Sorbet typed: strict 2024-08-10 00:23:29 +01:00
なつき
2e2db25496 Use spawn to replace fork + exec 2024-08-09 14:16:36 -07:00
なつき
5442a7e34f Honor homebrew curlrc config for analytics 2024-08-09 14:16:36 -07:00
Carlo Cabrera
ab4f14b359
utils/analytics: improve accuracy of GitHub Packages download counts
`millions_match.captures.first` will typically be a decimal (since it's
matched using `\d+\.\d+`), except we lose accuracy in the `#to_i`
conversion.

Before:
```
❯ brew info --analytics --github-packages-downloads sqlite
==> Analytics
==> install (30 days)
[snip]
==> GitHub Packages Downloads
1,009,898 (30 days)
```

After:

```
❯ brew info --analytics --github-packages-downloads sqlite
==> Analytics
==> install (30 days)
[snip]
==> GitHub Packages Downloads
1,199,898 (30 days)
```

In this case `1.19M` was being rounded down to `1M`.
2024-08-04 05:33:46 +08:00
Mike McQuaid
e3a1a9dccf
Improve locking UX
My experience recently playing around with our locking behaviour is
that, while mostly seamless and not seen by users, it's leaks
implementation details a bit too heavily.

As a result, the following improvements are in this commit:
- Ensure that, whenever possible, we tell the user the actual command
  that is holding a given lock instead of the lock name (an internal
  implementation detail)
- Make the locking error output a little more consistent and user
  friendly
- Add a `DownloadLock` class to simplify locking downloads
- Add a `HOMEBREW_LOCK_CONTEXT` variable to allow adding additional
  context for logging error messages
- Lock paths and leave deciding how this translates to lock names up
  to the locking code itself
- Lock the Cellar/Caskroom paths explicitly rather than implicitly

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-07-30 17:51:02 +01:00
Bo Anderson
a0a3333ee4
utils/github/api: fix encoding errors when reading from keychain 2024-07-30 04:51:00 +01:00
Issy Long
0af1ce866c
utils/github/api: Fix uninitialized constant Etc
- I saw this in:

```
Error: uninitialized constant GitHub::API::Etc
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/utils/github/api.rb:140:in `uid_home'
/opt/homebrew/Library/Homebrew/utils/github/api.rb:154:in `block in github_cli_token'
/opt/homebrew/Library/Homebrew/utils/uid.rb:8:in `drop_euid'
/opt/homebrew/Library/Homebrew/utils/github/api.rb:150:in `github_cli_token'
/opt/homebrew/Library/Homebrew/utils/github/api.rb:194:in `credentials'
/opt/homebrew/Library/Homebrew/utils/github/api.rb:251:in `open_rest'
/opt/homebrew/Library/Homebrew/utils/github/api.rb:334:in `open_graphql'
/opt/homebrew/Library/Homebrew/utils/github.rb:414:in `members_by_team'
/opt/homebrew/Library/Homebrew/dev-cmd/contributions.rb:71:in `run'
/opt/homebrew/Library/Homebrew/brew.rb:95:in `<main>'
```
2024-07-27 23:45:16 +01:00
Sam Ford
a6e61fd664
contributions, github: reorder requires
Per feedback to https://github.com/Homebrew/brew/pull/17806, this
moves some `require` statements in `dev-cmd/contributions.rb` and
`Utils::GitHub` into the methods that need them.
2024-07-25 10:02:18 -04:00
Bo Anderson
e6348b186f
Merge pull request #17851 from Homebrew/misconfigured-nss-fix
utils/github/api: handle systems with misconfigured NSS
2024-07-25 04:47:43 +01:00
Bo Anderson
d39a3a3030
Merge pull request #17788 from Homebrew/more-sorbet-strict
sorbet: Bump more files to `typed: strict`
2024-07-25 02:23:23 +01:00
Bo Anderson
40ca1de617
utils/github/api: handle systems with misconfigured NSS 2024-07-25 01:57:06 +01:00
Sam Ford
a9f7da36e0
contributions, github: add missing requires
This resolves `unitialized constant` errors in `brew contributions`
(`Tap`, `GitHub`) and `Utils::GitHub` (`Utils::Curl`).

This also preemptively adds some requires to `Utils::GitHub` and
`GitHub::API`, to avoid similar errors.
2024-07-18 12:55:41 -04:00
Issy Long
b033119523
utils/github/actions: Bump to Sorbet typed: strict 2024-07-17 18:00:20 -04:00
Issy Long
07f9f3f8e0
utils/github/artifacts: Bump to Sorbet typed: strict 2024-07-17 18:00:20 -04:00
Issy Long
5b84ee0195
utils/tar: Bump to Sorbet typed: strict 2024-07-17 18:00:20 -04:00
Rylan Polster
9538f424b5
Merge pull request #17762 from samford/formula-require-utils-backtrace 2024-07-16 12:41:19 -04:00