44 Commits

Author SHA1 Message Date
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
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
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
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
5e636174e8
Explicitly mark non-public APIs. 2024-04-23 19:10:45 +02:00
Markus Reiter
4b432c7ea4
Explicitly mark non-private APIs. 2024-04-22 21:16:49 +02:00
William Woodruff
0f0dee42b4
ensure_executable!: add opt_bin path to search
Signed-off-by: William Woodruff <william@yossarian.net>
2024-04-18 11:11:26 -07:00
Mike McQuaid
f086138043
Fix GitHub Actions annotation format.
Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-03-14 14:09:11 +00:00
Mike McQuaid
dcaa69a2dc
Add GitHub Actions warning/error annotations for deprecations/disables.
This should make these messages, particular warnings, more obvious to
GitHub Actions users.

There's an argument perhaps we should do this more broadly for all
warning/error messages but: this feels like a good start.
2024-03-14 09:49:12 +00:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +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
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Bo Anderson
7187b8b5d6
extend/kernel: fix odisabled kwargs handling 2023-10-28 17:48:31 +01:00
Markus Reiter
16aa6372a3
Make odebug output to stderr. 2023-10-10 03:42:22 +02:00
Eric Knibbe
931f762598
docs+rubydoc: various grammar/wording fixes 2023-09-11 02:26:37 -04:00
Eric Knibbe
31a5df4bf2
extend/kernel: convert TTY-destined input to string 2023-08-02 09:22:15 -04:00
Mike McQuaid
7da934f7e2
Deprecate/disable/delete code.
The next release after this is merged will be 4.1.0.

Co-authored-by: Markus Reiter <me@reitermark.us>
2023-07-06 16:56:20 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Dustin Rodrigues
b776fb32de
change includecount to include_count for readability 2023-03-20 07:23:17 -04:00
Dustin Rodrigues
e5fba88035
use includecount argument in pluralize 2023-03-19 23:35:47 -04:00
Douglas Eichelberger
cc5b013cb9 Remove compatibility layer 2023-03-14 14:49:34 -07:00
Douglas Eichelberger
a1748605ab Minor Kernel cleanup 2023-03-14 10:27:16 -07:00
Douglas Eichelberger
f4c9a96c70 Enable types in dev-cmd 2023-03-14 08:32:03 -07:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Issy Long
89fb8c78e8
rubocop: Drop "s" from Naming/MethodParameterName allowlist
- Most usages of this were in the `pretty_duration` method, where "s"
  is better described as "seconds" since we're calculating a duration.
- I also took the executive decision to do the same to "m" which refers
  to "minutes".
2023-03-08 14:42:53 +00:00
Douglas Eichelberger
7aab1c2a38 Remove ActiveSupport String inflections 2023-03-07 10:16:52 -08:00
Douglas Eichelberger
0d200944c8 Move nostdout to lone calling class 2023-03-03 08:30:15 -08:00
Douglas Eichelberger
d98b7845d3 Enable typing in misc files 2023-03-03 08:29:26 -08:00
Mike McQuaid
7c15dce285
Merge pull request #14798 from MikeMcQuaid/deprecate_shell
Deprecate `preferred_shell` and `shell_profile`.
2023-02-28 15:18:00 +00:00
Mike McQuaid
32463227ac
Deprecate preferred_shell and shell_profile.
I know that we're outside our normal deprecation cycle but: these are
totally broken with the API and it doesn't make sense to support them
only for non-core formulae.
2023-02-28 15:02:06 +00:00
Issy Long
267d72a9d0
More comments and TODOs
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-02-28 12:50:05 +00:00
Issy Long
316df75da9
utils: Add a comment to module Kernel to appease RuboCop
- This `Homebrew/utils.rb` file contains one `@api public` method so it's now
  included in `Style/Documentation`.
- This method not having a comment was causing the style specs to fail because
  this file isn't usually failing RuboCop.
- And the test description was confusing so I improved it.
2023-02-28 00:18:52 +00:00
Douglas Eichelberger
2b4d4a3707 Isolate Kernel extensions 2023-02-27 11:22:10 -08:00
Douglas Eichelberger
ff48ce24c4 Copy utils.rb into extend/kernel.rb 2023-02-27 11:19:11 -08:00