1561 Commits

Author SHA1 Message Date
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
Bo Anderson
af429d4f1a
utils/analytics: fix handling of newlines 2024-07-16 17:06:38 +01:00
Sam Ford
11d6785bea
Add utils/backtrace requires
This is primarily intended to resolve the `uninitialized constant
Utils::Backtrace` error in `formula_versions.rb:60` but I expanded it
to try to cover all existing usage of `Utils::Backtrace`.

I've followed the existing pattern, where `utils/backtrace` is
required in the context of where it's used. Many of these cases use
`Backtrace` in a conditional manner, so I've tried to ensure that the
`require` follows suit.
2024-07-15 17:48:47 -04:00
William Woodruff
79dabc918b
utils/pypi: add missing import
This was transitively imported before.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-15 09:34:15 -04:00
Markus Reiter
988c44ce20
Merge pull request #17722 from reitermarkus/ignore-interrupts
Make `ignore_interrupts` thread-safe.
2024-07-14 15:25:34 -04:00
Markus Reiter
447216a960
Avoid ignore_interrupts in safe_fork. 2024-07-14 14:32:49 -04:00
Mike McQuaid
55c0a9d3b4
Merge pull request #17729 from Homebrew/utils_analytics_strip 2024-07-14 14:11:19 -04:00
Markus Reiter
6f58bffc5c
Remove useless ignore_interrupts. 2024-07-14 13:48:23 -04:00
William Woodruff
a6e6837077
Merge pull request #17724 from Homebrew/ww/fix-local-bottles 2024-07-14 13:32:36 -04:00
Markus Reiter
3c8497647e
Fix unused argument. 2024-07-14 13:18:33 -04:00
Mike McQuaid
2d345d89eb
utils/analytics: strip out more data.
We've filter this out in `brew formula-analytics` too but let's avoid
sending it here in the first place so we can delete the
formula-analytics filtering later.
2024-07-14 13:15:09 -04:00
William Woodruff
e8ce1841d5
pypi: source wheel -> universal wheel
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-14 12:51:41 -04:00
William Woodruff
547e33ccb7
pypi: allow source wheels as resources
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-14 11:58:36 -04:00
Mike McQuaid
b8ff4b3d23
Widen attestation verification rollout
Take 2 of https://github.com/Homebrew/brew/pull/17692 but with:

- provide and document `HOMEBREW_NO_VERIFY_ATTESTATIONS`
- don't try to run unless there's GitHub credentials
- don't try to run unless `gh` is installed
- don't try to run in CI

While we're here:
- split out a `Homebrew::EnvConfig.devcmdrun?` helper method
- add some missing `Homebrew::EnvConfig.github_api_token` presence
  checks
2024-07-14 11:50:57 -04:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Mike McQuaid
f39b5c1426
Merge pull request #17554 from Homebrew/cask-install-receipt 2024-07-13 10:55:06 -04:00
Issy Long
bd9c7777e8
utils/shebang: Convert to Sorbet typed: strict 2024-07-05 15:37:59 +01:00
Rylan Polster
acd60181c2
Add cask install receipts 2024-07-04 01:47:13 -04:00
Rylan Polster
e28d455154
autoremove: skip formulae where installed_on_request is nil 2024-06-28 21:57:47 -04:00
Bo Anderson
2b454328ca
Remove non-Portable Ruby bootsnap support 2024-06-19 16:08:05 +01:00
Bo Anderson
1e7cf514eb
utils/gems: handle mismatching EUID and UID for bundle installs 2024-06-18 14:42:45 +01:00
Kevin
c3c1528611
Revert "Use cp -c when copying files" 2024-06-17 21:17:10 -07:00
Mike McQuaid
a883f14b72
autoremove: don't remove formulae that were built from source
When a formula was built from source, it should not be removed by
`brew autoremove` as it will take a while to be installed again.

Fixes https://github.com/Homebrew/brew/issues/17433
2024-06-14 17:26:28 +01:00
Mike McQuaid
b38e14bce7
Further Portable Ruby cleanup
- Use the `HOMEBREW_PORTABLE_RUBY_VERSION` environment variable to
  determine the version of the Portable Ruby to use in
  `vendor-install.sh` and `ruby.sh`.
- Replace the `docs/.ruby-version` file with a symlink to
 `Library/Homebrew/.ruby-version`.
- Fix an incorrect `HOMEBREW_LIBRARY` comment.
- Use a simpler `HOMEBREW_USING_PORTABLE_RUBY` definition.
2024-06-14 12:22:02 +01:00
Mike McQuaid
9e0cbe0fd7
Rename variable to HOMEBREW_USING_PORTABLE_RUBY 2024-06-14 12:06:06 +01:00
Bo Anderson
24f74c0528
Merge pull request #17501 from Homebrew/portable-ruby-3.3.3
Portable Ruby 3.3.3
2024-06-14 04:34:01 +01:00
Bo Anderson
fa91edadfd
Portable Ruby 3.3.3 2024-06-14 03:32:38 +01:00
Bo Anderson
fa2731d0c7
cmd/setup-ruby: fix Portable Ruby install failing 2024-06-14 02:26:16 +01:00