2325 Commits

Author SHA1 Message Date
Mike McQuaid
6105728c31
Merge pull request #18004 from Homebrew/more-srb-strict 2024-08-12 14:22:00 +01:00
Issy Long
fc3c138cb0
extend/os/linux/cmd/update-report: Bump to Sorbet typed: strict 2024-08-10 23:55:14 +01:00
Issy Long
c62ee6be6c
extend/os/mac/utils/bottles: Bump to Sorbet typed: strict 2024-08-10 00:21:13 +01:00
Issy Long
0e81efcccb
sorbet: Comment more files that can't be strict because of undef
- Found with
  `grep -rL "# typed: strict" Library/Homebrew | xargs grep -l "undef "`.
- This stops people from trying to bump them and
  getting an error that they can't fix because
  [it's a Sorbet limitation](https://sorbet.org/docs/error-reference#3008),
  wasting contributor time.
2024-08-09 18:23:00 +01:00
Adrian Ho
3eaebdc9d8
diagnostic: fix XDG_DATA_DIRS check
Pass `XDG_DATA_DIRS` through `bin/brew` so that it can be checked.
2024-08-05 09:11:01 +01:00
Michael Cho
0477944e71
shims/super/cc: pass -ld_classic if needed for -dead_strip_dylibs 2024-08-03 14:46:18 -04:00
William Woodruff
107d57d220
extend/kernel: forward the latest: kwarg
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-29 13:43:42 -04:00
William Woodruff
5e0e0d56af
attestation: remove gh version detection
I'm declaring bankruptcy on this entire approach:

1. We can attempt to match on versions, but this will fail
   when the version of `gh` installed is built from `HEAD`
   or similar.
2. We can match on dates instead (since `gh --version` also includes
   the date), but this is even more brittle + implies a support
   contract we don't actually have (we don't actually want
   to say we support random dated builds between public releases
   of `gh`).

This moves us back to a simpler approach: if `gh` is present,
we use it. If `gh` is not present, we attempt to install it
with `ensure_executable!`. If the user's `gh` is present but too old,
it'll fail during attestation verification with a reasonable error,
which IMO is fine for now since this is all still in beta.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-29 13:13:55 -04:00
Mike McQuaid
42438f45ae
extend/kernel: add missing utils require.
Don't require this globally to avoid slowing down boot.
2024-07-26 19:48:51 +01:00
Markus Reiter
b8847a90d9
Remove unused argument. 2024-07-14 15:08:37 -04:00
Markus Reiter
44766945fc
Fix variable type. 2024-07-14 14:32:17 -04:00
Markus Reiter
27a70a40c2
Disallow nested ignore_interrupts. 2024-07-14 13:36:43 -04:00
Markus Reiter
3c8497647e
Fix unused argument. 2024-07-14 13:18:33 -04:00
Markus Reiter
bcded854ce
Make ignore_interrupts thread-safe. 2024-07-14 11:43:14 -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
Issy Long
9c6430954b
All the extract_to_dirs return void now 2024-07-11 11:05:47 +01:00
Eric Knibbe
3f73f32286
cask/audit: handle on_os range bounded by depends_on 2024-07-01 23:11:26 -04:00
Henry
22d42efb5c
Use effective_arch for rustflags 2024-06-30 02:23:29 -04:00
Eric Knibbe
f627c6331d
cask/audit: support on_os blocks in audit_min_os 2024-06-21 19:25:51 -04:00
Kevin
c3c1528611
Revert "Use cp -c when copying files" 2024-06-17 21:17:10 -07:00
Mike McQuaid
1e0add6d66
Merge pull request #17373 from tesaguri/cp-reflink 2024-06-13 08:57:20 +01:00
Daiki Mizukami
a30cd15a73
extend/os/mac/utils/copy: typed: strict 2024-06-13 06:56:18 +09:00
Daiki Mizukami
028cfe1ea6
Utils::Cp: Rename to Utils::Copy
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#discussion_r1633217748
2024-06-11 20:31:34 +09:00
Daiki Mizukami
eab1e87726
Utils::Cp: Deduplicate SystemCommand invocations 2024-06-09 22:59:24 +09:00
Daiki Mizukami
67f280eb53
Utils::Cp: Add force_system keyword argument
This fixes the test for `UnpackStrategy::Directory`, which needs the
`cp` command.
2024-06-09 07:57:56 +09:00
Daiki Mizukami
9156891c99
Utils::Cp: Use FileUtils.cp on Linux
`FileUtils.cp` is implemented with the lightweight `copy_file_range(2)`
syscall on Linux, so it's more performant than the plain `cp` command on
that platform.

cf. https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2105629022
2024-06-08 20:25:19 +09:00
Daiki Mizukami
b2ddeecdd9
Utils::Cp: Remove copy prefix from method name
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2104523770

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-06-08 07:58:20 +09:00
Daiki Mizukami
7cfcc596b9
Utils::Cp: Move macOS-specific code to extend/os/mac 2024-06-07 19:03:48 +09:00
Daiki Mizukami
58852106c1
Utils::Cp: Rename copy* methods to copy*_with_attributes
As per review feedback:

https://github.com/Homebrew/brew/pull/17373#pullrequestreview-2103870774
2024-06-07 19:03:33 +09:00
Issy Long
509fffab2b
Make more files Sorbet typed: strict
- According to Spoom, these could be bumped automatically with no errors.
2024-06-02 15:15:24 +01:00
Mike McQuaid
e573a53868
Output GitHub warning/error annotations to stderr
This will mean e.g. `opoo` etc. will output to stdout and not end up
being in the stdout of `brew deps` etc.

While we're here, remove a duplicate annotation output I noticed in
`extend/kernel.rb`.

Inspired by conversation in:
https://github.com/Homebrew/homebrew-test-bot/issues/1082
2024-05-31 09:31:44 +01:00
Daiki Mizukami
deaac7ce47
Use Utils::Cp to copy files
This replaces `FileUtils.cp` and `system_command! "cp"` with the new
`Utils::Cp` utility where it is expected that the performance
improvement outweighs the cost of the system command invocation.
2024-05-27 12:11:41 +09:00
Mike McQuaid
6e9288470e
brew style --fix 2024-05-23 17:15:43 +01:00
Mike McQuaid
a92e6fc1c8
extend/pathname: import rmtree again.
The separate file is no longer required now that
https://github.com/sorbet/sorbet/pull/7895 was merged.
2024-05-18 18:02:31 +02:00
Mike McQuaid
cc11da6bdd
extend/pathname/rmtree: improve comment.
Clarify that this can't easily be `odeprecated` but keep the wording
around so that we remember to do this on the next minor release.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
2024-05-17 14:22:42 +09:00
Bo Anderson
727cf5e917
extend/pathname: restore old rmtree behaviour 2024-05-17 12:32:29 +09:00
Carlo Cabrera
cc65e5419d
linkage_checker: remove gcc from @indirect_deps on Linux
Closes #17303.
2024-05-16 00:47:21 +08:00
Patrick Linnane
992b50a413
various: fix minor typos
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-05-13 14:30:06 -07:00
Mike McQuaid
50384591c7
extend/kernel: add sigs to opoo/onoe/ofail
Add these and correctly pass through a string to
`GitHub::Actions.puts_annotation_if_env_set`.

Also, fix some call sites to not rely on the `void` return.
2024-05-10 14:12:19 +01:00
Mike McQuaid
16901a674f
extend/kernel: make opoo/odie/etc. print GitHub Actions notes.
We already do this for deprecations but these may make warnings
and errors from Homebrew easier to spot in GitHub Actions logs.

While we're here, cleanup other cases that should have used
`GitHub::Actions::Annotation` but didn't and provide some helpers and
tweaks there necessary for our use case here.
2024-05-09 14:43:53 +01:00
apainintheneck
37cbfc40bf Fix internal formula json v3 frozen hash parsing bug
This caused formulae with uses from macos bounds to not load correctly
because they tried to modify a frozen hash. It wasn't obvious from
the tests because I didn't replicate the real world JSON parsing
conditions closely enough. I also had to modify `Cachable#clear_cache`
so that it can clear frozen hashes.

Error:
```
Error: can't modify frozen Hash: {"since"=>"catalina"}
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:123:in `delete'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:123:in `block in _deep_transform_keys_in_object!'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:122:in `each'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:122:in `_deep_transform_keys_in_object!'
/usr/local/Homebrew/Library/Homebrew/extend/hash/keys.rb:48:in `deep_transform_keys!'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:230:in `block (2 levels) in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:218:in `each'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:218:in `block in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:304:in `instance_exec'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:304:in `block (2 levels) in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formula.rb:3664:in `instance_eval'
/usr/local/Homebrew/Library/Homebrew/formula.rb:3664:in `stable'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:293:in `block in load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `initialize'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `new'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:283:in `load_formula_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:962:in `load_from_api'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:955:in `klass'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:569:in `get_formula'
/usr/local/Homebrew/Library/Homebrew/formulary.rb:1009:in `factory'
/usr/local/Homebrew/Library/Homebrew/dependency.rb:41:in `to_formula'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:46:in `block (2 levels) in formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:45:in `each'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:45:in `block in formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:39:in `each'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:39:in `formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:59:in `unused_formulae_with_no_formula_dependents'
/usr/local/Homebrew/Library/Homebrew/utils/autoremove.rb:16:in `removable_formulae'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:693:in `autoremove'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:291:in `clean!'
/usr/local/Homebrew/Library/Homebrew/cmd/cleanup.rb:52:in `run'
/usr/local/Homebrew/Library/Homebrew/brew.rb:92:in `<main>'
```
2024-05-01 21:36:37 -07:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
f7361c8d29
Remove disabled extend. 2024-04-30 11:01:12 +02:00
Markus Reiter
0b56d0be4a
Document Tab.for_keg and use Keg#tab where possible. 2024-04-28 20:50:13 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
af31d36295
Merge pull request #17156 from reitermarkus/unused-method
Remove unused private method.
2024-04-26 15:03:32 +01:00
Markus Reiter
7c8c75aa37
Remove unused method. 2024-04-26 12:34:50 +02:00
Carlo Cabrera
e3e927f688
Merge pull request #17104 from Homebrew/llvm-library-paths
extend/ENV/super: avoid adding `llvm` to `HOMEBREW_LIBRARY_PATHS`
2024-04-24 17:16:10 +08:00
Markus Reiter
5e636174e8
Explicitly mark non-public APIs. 2024-04-23 19:10:45 +02:00