5321 Commits

Author SHA1 Message Date
Issy Long
b0154f36a5
cmd/uses: Bump to Sorbet typed: strict 2024-08-10 23:55:14 +01:00
Issy Long
10dc874b1e
cmd/tap-info: Bump to Sorbet typed: strict 2024-08-10 23:55:14 +01:00
Issy Long
4ff3e370e0
cmd/outdated: Bump to Sorbet typed: strict 2024-08-10 23:55:13 +01:00
Issy Long
6d8c21bd7a
cmd/leaves: Bump to Sorbet typed: strict 2024-08-10 23:55:13 +01:00
Issy Long
686b5afa05
cmd/list: Bump to Sorbet typed: strict 2024-08-10 23:55:13 +01:00
Scott Searcy
17855638c2 Update Fish shell environment script
Fish didn't support `$(...)` substitution until v3.4.0, but the command
didn't work with just parenthesis, so rewrite the test to prepend an
empty string if MANPATH is non-empty (to trigger a leading colon).
Only manipulate INFOPATH in Fish if Homebrew not in path already.
2024-08-10 14:34:59 -07:00
Issy Long
6cc4d6dacb
cmd/--prefix: Bump to Sorbet typed: strict 2024-08-10 22:17:05 +01:00
apainintheneck
a3e917afe1 Refactor method to remove extra tap requires
We were selectively requiring the tap.rb file in a few places for
performance reasons. The main method we were referencing was the
`Tap.cmd_directories` method which uses `Pathname` and the `TAP_DIRECTORY`
constant internally. `Tap.cmd_directories` is mostly used in the `Commands`
module and that is loaded very early on in the program so it made sense
to move that command to that module. To facilitate that I moved the
`TAP_DIRECTORY` constant to the top-level and renamed it to
`HOMEBREW_TAP_DIRECTORY`. It now lies in the tap_constants.rb file.

A nice bonus of this refactor is that it speeds up loading external
commands since the tap.rb file is no longer required by default in
those cases.
2024-08-10 13:49:10 -07:00
Bo Anderson
c3d9e8e6f1
cmd/update: make chown suggestion consistent 2024-08-06 21:42:50 +01:00
Carlo Cabrera
3fec77e72a
shellenv: fix MANPATH and INFOPATH handling for [t]csh
It turns out that control flow in csh is a pain. But we can rely on
`test`, which is thankfully POSIX.

Closes #17949.
2024-08-04 02:52:14 +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
Ruoyu Zhong
fa63211acf
Merge pull request #17850 from Homebrew/repository-prefix-fix
cmd/--repository: fix homebrew- prefix handling
2024-07-25 09:54:37 +08: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
38987be01f
cmd/--repository: fix homebrew- prefix handling 2024-07-25 01:42:53 +01:00
Issy Long
6ad0ebd5b4
env_config: Tighten hash types some more
Co-authored-by: Bo Anderson <mail@boanderson.me>
2024-07-24 23:16:58 +01:00
Bo Anderson
1ce88d4992
cmd/update: silence git advice where possible 2024-07-23 18:54:05 +01:00
Kevin
d686be67c6
Merge pull request #17761 from eaze/cask-quiet-upgrade
Add better "--quiet" support to cask upgrade
2024-07-19 22:54:51 -07:00
Eric Sampson
8bb1ba13be silence no-op upgrade warning in upgrade.rb 2024-07-19 09:26:05 -05:00
apainintheneck
52cf4e30fc Share attestation formula sorting and gh exe checking logic
This adds a new method to either move the `gh` formula to the front
of the formula list to be installed or checks that the `gh` formula
is already installed some other way.
2024-07-18 21:32:50 -07:00
apainintheneck
75cfa21068 Avoid frozen array errors in brew upgrade
The `Homebrew::CLI::NamedArgs` class often returns frozen arrays so this one cannot
be easily modified in-place here. We just overwrite it instead.

I also updated the `brew reinstall` command logic to match for consistency.

```console
$ brew upgrade gh --verbose --debug
...
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading gh
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading gh
Error: can't modify frozen Array: [#<Formula gh (stable) /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/g/gh.rb>]
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:139:in `delete'
/usr/local/Homebrew/Library/Homebrew/cmd/upgrade.rb:139:in `run'
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11481/lib/types/private/methods/call_validation.rb:270:in `bind_call'
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11481/lib/types/private/methods/call_validation.rb:270:in `validate_call'
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.3.0/gems/sorbet-runtime-0.5.11481/lib/types/private/methods/_methods.rb:277:in `block in _on_method_added'
/usr/local/Homebrew/Library/Homebrew/brew.rb:95:in `<main>'
```
2024-07-17 23:54:50 -07:00
Nanda H Krishna
8839ccfe72
Fix tests for attestations 2024-07-17 14:48:53 -04:00
Nanda H Krishna
81e606007f
Fix type errors 2024-07-17 14:48:52 -04:00
Nanda H Krishna
d2d814414e
cmd/{install,reinstall,upgrade}: ensure that gh is installed 2024-07-17 14:48:52 -04:00
Nanda H Krishna
51ec743d6f
Remove ensure_gh_installed!
Co-authored-by: William Woodruff <william@yossarian.net>
2024-07-17 14:48:52 -04:00
Nanda H Krishna
4d387d285e
Fix type and style errors 2024-07-17 14:46:59 -04:00
Nanda H Krishna
3bb91601fb
Ensure early installation of gh for attestations 2024-07-17 14:46:58 -04:00
Rylan Polster
9538f424b5
Merge pull request #17762 from samford/formula-require-utils-backtrace 2024-07-16 12:41:19 -04: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
Ruoyu Zhong
0e111e39a9
cmd/vendor-install: use ShellCommand 2024-07-15 14:48:37 -04:00
Ruoyu Zhong
1b62371455
cmd/update: use ShellCommand 2024-07-15 14:48:37 -04:00
Ruoyu Zhong
fdeb61094c
cmd/update-reset: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
02aaf67d55
cmd/shellenv: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
f7e3873ecd
cmd/setup-ruby: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
e0db9061d1
cmd/formulae: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
2ef745445b
cmd/casks: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
06610bf807
cmd/--version: use ShellCommand 2024-07-15 14:48:36 -04:00
Ruoyu Zhong
23db47dba5
cmd/--repository: use ShellCommand 2024-07-15 14:48:36 -04:00
Eric Sampson
d40ab11784 Add "-quiet" support to cask updgrade 2024-07-15 11:50:37 -05:00
Mike McQuaid
835c2f2e2b
Merge pull request #17742 from Homebrew/ruby_bash_commands_integrations 2024-07-15 16:10:31 +02:00
Patrick Linnane
4b749546aa
cmd/tap: add missing require
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-07-14 23:20:50 -04:00
Ruoyu Zhong
e806870f85
cmd/update-reset.rb: the named args are repos not taps 2024-07-14 23:12:53 -04:00
Mike McQuaid
5987c5c1d0
Add stub Ruby commands for all Bash commands.
This gets us pretty similar (but easier to manage) manpage output but
much nicer completions etc. for all these commands.
2024-07-14 23:12:53 -04:00
Mike McQuaid
fd62a158f2
Merge pull request #17728 from Homebrew/sponsors-maintainers-man-completions 2024-07-14 15:00:20 -04:00
Mike McQuaid
8ae18f463e
cmd/--repository.rb: tweak error message. 2024-07-14 14:46:59 -04:00
Ruoyu Zhong
3bc01a4d31
Fix completion generation for --repository 2024-07-14 14:46:59 -04:00
Rylan Polster
5030ad6f28
Require utils/backtrace when install fails 2024-07-14 14:37:30 -04:00
Mike McQuaid
4d1e601ecb
Merge pull request #17721 from Homebrew/deprecated_packages_disable_date 2024-07-14 14:15:05 -04:00
Ruoyu Zhong
64838db963
cmd/--repository: improve tap name error checking
Before:

    $ brew --repo core
    /usr/local/Homebrew/Library/Taps/core/homebrew-core

After:

    $ brew --repo core
    Error: Invalid tap name: core
2024-07-14 13:17:26 -04:00
Mike McQuaid
2d26c89e81
Merge pull request #17726 from Homebrew/brew-repository-speedup 2024-07-14 12:57:52 -04:00
Ruoyu Zhong
96cf5513c8
Port brew --repository to Bash
This provides a significant speedup:

    $ hyperfine 'git checkout master; brew --repo homebrew/core' 'git checkout brew-repository-speedup; brew --repo homebrew/core'
    Benchmark 1: git checkout master; brew --repo homebrew/core
      Time (mean ± σ):      1.737 s ±  0.388 s    [User: 0.743 s, System: 0.323 s]
      Range (min … max):    1.336 s …  2.438 s    10 runs

    Benchmark 2: git checkout brew-repository-speedup; brew --repo homebrew/core
      Time (mean ± σ):     459.1 ms ±  91.9 ms    [User: 100.5 ms, System: 142.1 ms]
      Range (min … max):   366.5 ms … 594.0 ms    10 runs

    Summary
      git checkout brew-repository-speedup; brew --repo homebrew/core ran
        3.78 ± 1.13 times faster than git checkout master; brew --repo homebrew/core
2024-07-14 12:07:11 -04:00