1028 Commits

Author SHA1 Message Date
Mike McQuaid
b87d2887fe
Merge pull request #20033 from tyuwags/master
Refine ask‐option dependency resolution and strengthen tests
2025-06-26 10:52:46 +00:00
Mike McQuaid
05c7b65f54
tab, cask/tab: add more Sorbet types and signatures.
I bailed before going all the way to `typed: strict` but this should at
least improve things and fix:

`Library/Homebrew/tab.rb:111: warning: The class Tab reached 8 shape variations, instance variables accesses will be slower and memory usage increased.`
2025-06-24 12:06:55 +01:00
thibhero
052c0ae2cd adding parameter to fetch quietly if wanted 2025-06-20 12:25:12 -04:00
Mike McQuaid
e9f55a8f71
tests: default to API mode enabled.
While we're here, also add `brew tests --no-parallel` which I relied
on during testing.

Pretty much anywhere we rely on a stubbed formula on disk to work: we
need to disable the API.
2025-06-10 15:53:27 +01:00
Mike McQuaid
ff710f8191
Improve completions (and elisp) output in caveats
Instead of repeatedly outputting the same identical messages across
multiple packages and repeating them all for every package after they
were all installed: just output the identical messages in the final
caveats output instead.
2025-06-06 17:09:28 +01:00
Bo Anderson
9ae847dcae
formula_installer: always output errors with fixing linkage 2025-04-24 17:20:35 +01:00
Mike McQuaid
d899f00c4b
Link to Support Tiers in diagnostic/error messages
Now that we have this nice URL let's reference it to allow our other
messages to be a bit shorter/kinder.
2025-04-01 11:35:27 +01:00
Douglas Eichelberger
fcf18912fe
Inline use of attr_predicate 2025-03-02 21:36:03 -08:00
Mike McQuaid
7a5d4256e5
Fix Rubocop warnings (without brew style --fix) 2025-02-28 09:59:32 +00:00
Douglas Eichelberger
a81239ec2d
Enable strict typing in Formula 2025-02-24 10:23:42 -08:00
Mike McQuaid
b49625a7dc
Add brew install --skip-link
We already have `--skip-post-install` and this adds similar behaviour
for e.g. `brew bundle` (and other users) to be able to install a
formula but skip the `brew link` stage afterwards.
2025-01-23 14:42:03 +00:00
Mike McQuaid
e6b8ed8940
formula_installer: improve quiet output.
Quieten a few warnings, messages and caveats if we're passing `--quiet`
to `brew install`.

This also quiets an incorrect "Fetching" message that was being shown
when installing from a local bottle.
2025-01-23 14:06:39 +00:00
Issy Long
4c9de7d31c
Merge pull request #19084 from Homebrew/add-comments-to-rubocop-disables
Add clarifying comments to `rubocop:disable`s
2025-01-13 11:32:31 +00:00
Mike McQuaid
0940fb78dc
Fix usage of Tab#installed_(on_request|as_dependency)
These can return `true`, `false` or `nil` so adjust the signature to
note this and fix the call sites to ensure we don't accidentally pass
through `nil` values when we shouldn't.

While we're here, make a `TODO` to fix this bad API up in future.

Fixes https://github.com/Homebrew/brew/issues/19076
2025-01-13 09:24:42 +00:00
Issy Long
6ada9a9665
Add clarifying comments to rubocop:disables
- Needed for PR 18842 that adds a `DisableComment` RuboCop to ensure that all RuboCop disables have comments.
2025-01-12 16:59:07 +00:00
Patrick Linnane
ba8d449073
formula_installer: allow installing/upgrading disabled formulae
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-11-25 08:57:31 -08:00
Eric Knibbe
86ada937cb
formula_installer: re-enable mirror usage when installing via API 2024-11-21 16:55:19 -05:00
Mike McQuaid
4d4531c19d
Revamp installed_on_request handling
- `reinstall` and `upgrade` no longer mark as installed on request,
  with or without names specified, but preserve the version from the
  tab instead
- default `install_on_request` to `false` rather than `true`
- only set installed in request in a tab if it's missing rather than
  false

Co-authored-by: Michael Cho <michael@michaelcho.dev>
2024-11-19 08:39:55 +00:00
Muneeb Ahmed
d33c5b31bf filter pinned test dependencies 2024-10-21 02:41:07 -07:00
Mike McQuaid
dd7d91bc6f
Improve/fix HOMEBREW_FORBIDDEN_LICENSES handling
`HOMEBREW_FORBIDDEN_LICENSES` now actually checks for valid SPDX license
identifiers rather than requiring the user to guess.

When an identifier is invalid, it will be ignore and warned about
instead.
2024-10-17 08:34:03 +01:00
Carlo Cabrera
aedbf7ac43
formula_installer: verify attestations at bottle fetch time
See discussion at #18544.
2024-10-14 14:08:54 +08:00
William Woodruff
0613050d59
attestation: specialize error on incompatible gh
Signed-off-by: William Woodruff <william@yossarian.net>
2024-10-10 12:06:09 +01:00
Douglas Eichelberger
2d16333bbc Replace removable constants with overridable methods 2024-10-07 18:33:03 -07:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -07:00
Mike McQuaid
94416e82f0
Add new odeprecated, odisabled, remove disabled code.
Prepare the usual deprecation cycle for Homebrew 4.4.0.
2024-09-24 10:15:34 +01:00
Bo Anderson
ca26080ef4
formula_installer: fix manifest error handling 2024-09-19 15:26:14 +01:00
Bo Anderson
a434e516cd
formula_installer: fix fetch call 2024-09-16 15:03:58 +01:00
Douglas Eichelberger
44970f728b clean up fetch_bottle_tab 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
17b6948933 Update Library/Homebrew/formula_installer.rb
Co-authored-by: Markus Reiter <me@reitermark.us>
2024-09-10 10:11:33 -07:00
Douglas Eichelberger
c2b9555d0b convert @etc_var_postinstall to an lvar 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
416ebda538 one line per param 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
ef33b35262 constantify @etc_var_dirs 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
0d44b110f9 fix regressions 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
659dd59234 Resolve runtime errors 2024-09-10 10:11:33 -07:00
Douglas Eichelberger
8a3f82158c Strict type FormulaInstaller 2024-09-10 10:11:33 -07:00
Mike McQuaid
c8e8aa5600
Merge pull request #17756 from reitermarkus/concurrent-downloads
Implement concurrent downloads in `brew fetch`.
2024-09-09 08:41:11 +01:00
Douglas Eichelberger
5d5daaa09f Use FormulaInstaller OS extensions 2024-09-06 13:58:32 -07:00
Markus Reiter
fb0bf3b7a2
Fix wrong stage method being called. 2024-09-05 00:21:33 +02:00
Markus Reiter
404176af1d
Implement Downloadable for more types. 2024-09-04 22:54:28 +02:00
Bo Anderson
6a0db5035f
Fix misuse of fork in sandbox causing crashes 2024-08-28 13:53:01 +01: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
Bo Anderson
040372fafa
Vendor SBOM schema 2024-08-07 18:00:53 +01:00
Bo Anderson
131b930d89
attestation: only fallback to backfill on 404 2024-07-23 16:59:52 +01:00
Bo Anderson
16d547b030
attestation: handle bad configurations better 2024-07-18 16:11:25 +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
Mike McQuaid
001d318014
Merge pull request #17707 from Homebrew/optimise_requires 2024-07-14 09:01:42 -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
06daff1621
formula_installer: tweak style. 2024-07-13 16:05:35 -04:00
William Woodruff
e56fde6584
formula_installer: skip attestations on local_bottle_path
Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 16:02:12 -04:00
William Woodruff
570cf65523
attestations: widen the beta
This widens the beta to include people with developer mode enabled,
as well as those with HOMEBREW_DEVELOPER set in their environment.

Signed-off-by: William Woodruff <william@yossarian.net>
2024-07-13 10:51:49 -04:00