143 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
6297f98d06
Fix symlinked tap loading issue in cask loader
Co-authored-by: MikeMcQuaid <125011+MikeMcQuaid@users.noreply.github.com>
2025-09-12 09:02:43 +01:00
Mike McQuaid
a1f112f3fe
Move o* output methods to Utils::Output
This reduces the surface area of our `Kernel` monkeypatch and removes
the need to `include Kernel` in a bunch of modules.

While we're here, also move `Kernel#require?` to `Homebrew` and fully
scope the calls to it.
2025-08-20 19:20:19 +01:00
Bevan Kay
69145c911d
cask/dsl/rename: add api support 2025-08-19 11:47:15 +10:00
Patrick Linnane
2605529a90
brew style --fix 2025-08-13 12:23:12 -07:00
Rylan Polster
0f9fb4f29a
Use API helper methods 2025-08-12 17:04:15 -04:00
Rylan Polster
8aabee74a6
Store cask API data for use in to_hash_with_variations 2025-08-11 22:06:07 -04:00
Mike McQuaid
34bc30d639
Fix URI parser warning 2025-07-31 12:21:19 +01:00
Mike McQuaid
312f046302
Make --debug output a bit quieter by default
The `Formulary` and `system_command` debug output is incredibly verbose
by default and this is pretty annoying when all you want is to get
better backtraces when there's an error.

Instead, let's require `--verbose` and `--debug` for the noisiest output
message types.
2025-07-25 17:14:46 +01:00
Mike McQuaid
35407ab556
cask: move some files to strict Sorbet sigil. 2025-06-17 14:56:10 +01:00
Mike McQuaid
e7f667c198
cask_loader: improve error handling.
Handle weird edge cases where we try to read a cask from invalid paths.
2025-06-06 14:19:00 +01:00
Sam Ford
cf22382921
Curl: use typed: strict
This upgrades `utils/curl.rb` to `typed: strict`, which requires
a number of changes to pass `brew typecheck`. The most
straightforward are adding type signatures to methods, adding type
annotations (e.g., `T.let`) to variables that need them, and ensuring
that methods always use the expected return type.

I had to refactor areas where we call a `Utils::Curl` method and use
array destructuring on a `SystemCommand::Result` return value
(e.g., `output, errors, status = curl_output(...)`), as Sorbet
doesn't understand implicit array conversion. As suggested by Markus,
I've switched these areas to use `#stdout`, `#stderr`, and `#status`.
This requires the use of an intermediate variable (`result`) in some
cases but this was a fairly straightforward substitution.

I also had to refactor how `Cask::URL::BlockDSL::PageWithURL` works.
It currently uses `page.extend PageWithURL` to add a `url` attribute
but this reworks it to subclass `SimpleDelegator` and use an
`initialize` method instead. This achieves the same goal but in a way
that Sorbet can understand.
2025-01-14 08:14:39 -05:00
Carlo Cabrera
fe1f330e60
Revert "Deprecate installing casks/formulae from paths." 2024-09-27 10:17:04 +08:00
Mike McQuaid
bbdea29a0f
Deprecate installing casks/formulae from paths.
We've already disabled installing casks/formulae from URLs and we
regularly tell people not to install from paths so let's just deprecate
this behaviour entirely.

Even Homebrew developers do not need to work this way.
2024-09-26 20:25:07 +01:00
Rylan Polster
b1db0ee290
Rename load method when preferring installed casks 2024-09-10 13:54:12 -04:00
Rylan Polster
711d2220b8
Remove T.unsafe usage
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2024-09-10 13:44:30 -04:00
Rylan Polster
8cb62b1398
Set correct tap when loading installed casks 2024-09-10 13:34:40 -04:00
Douglas Eichelberger
fb2fdc5249 Minor type safety improvements 2024-08-18 18:16:39 -07: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
Douglas Eichelberger
c799f5f818 Allow Cask refs 2024-08-11 18:01:04 -07:00
Douglas Eichelberger
a41f15ede7 Make FromContentLoader.try_new typesafe 2024-08-11 17:10:55 -07:00
Bo Anderson
10cbf191dc
Add env to disable finding packages from paths 2024-07-25 11:37:44 +01:00
Rylan Polster
8b0a4a98bf
Restrict direct url installs to the file:// scheme 2024-07-13 13:30:36 -04:00
Rylan Polster
c16a9b33b2
Use cached json API file for formulae and cask specified paths 2024-07-03 13:41:52 -04:00
apainintheneck
16e605e056 Load tap migration renames from API with short names
This is a follow-up to 484498e. I added loading for tap migration
renames from the API but it apparently only worked for full names.

There was a bug in both the code and the tests which prevented
loading by short names. This fixes those bugs so everything should
be good now.
2024-07-01 18:53:31 -07:00
apainintheneck
10aa981209 Load tap migration renames from the API
These would not get loaded from the API at all meaning these
were not loadable by the old names when the core formula or cask
tap was not installed. We assume that most users don't have those
core taps tapped which means this is broken for most everyone.
2024-06-30 11:26:03 -07:00
Philippe Eberli
20fb068085 Fix migrations of formulae and casks to non homebrew taps 2024-06-08 16:29:23 +02:00
Kevin
c44e053847
Merge pull request #17242 from Homebrew/fix-cask-source-file-path-loading-issues
Fix cask source file path loading issues
2024-05-08 18:28:04 -07:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
apainintheneck
ffc503f1d0 Fix cask source file path loading issues
There are two big changes here. Both have to do with how we want
to load casks in different scenarios. One also is related to formulae.

1. Prevent loading casks & formulae outside of taps for specific commands.

There are certain commands like `bump`, `bump-*-pr`, `livecheck` and `audit`
where it really makes no sense to try and run things if the specified formulae
or cask is not in a tap. A new `#to_formulae_and_casks_with_taps` method was
added to the `CLI::NamedArgs` class to allow us to easily grab and validate
formulae and casks from named arguments.

2. Always load the source file path when loading casks with the path loader.

There was an edge case where all JSON cask files were being loaded without
setting the source file path because most of the work was handed off to the
API loader where that normally would make more sense. Now we set that when
calling the API loader which solves the problem. This improves the user
experience of people using the `--cache` and `fetch` commands in certain
edge cases. Hopefully it makes the user experience a bit more consistent.

A regression test was added for this point.
2024-05-06 23:34:23 -07:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
e575671477
Actually remove FromDefaultNameLoader. 2024-03-12 22:50:13 +01:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Markus Reiter
a24da6b072
Remove FromDefaultNameLoader to avoid warning twice. 2024-03-06 23:14:28 +01:00
Markus Reiter
a851bb86ef
Add type signature for Tap::fetch. 2024-03-06 14:30:17 +01:00
Mike McQuaid
f1eea64523
Merge pull request #16779 from reitermarkus/fix-load-from-path
Fix loading casks/formulae from relative paths.
2024-03-01 08:47:41 +00:00
Markus Reiter
3da0f8c4a6
Fix loading casks/formulae from relative paths. 2024-03-01 04:05:15 +01:00
Markus Reiter
755c8aecad
Simplify Tap#cask_files_by_name. 2024-02-29 22:47:43 +01: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
Markus Reiter
670eb3d02d
Remove CaskLoader::tap_paths. 2024-02-20 18:25:11 +01:00
Markus Reiter
876535c670
Use HOMEBREW_DEFAULT_TAP_CASK_REGEX in FromDefaultNameLoader. 2024-02-13 21:52:45 +01:00
Markus Reiter
d506645667
Add separate loader for default tap. 2024-02-13 21:25:52 +01:00
Markus Reiter
eaf7b38995
Allow tap migrations with renames. 2024-02-13 04:17:43 +01:00
Markus Reiter
c39abef045
Always prefer default tap. 2024-02-12 21:45:07 +01:00
Markus Reiter
48c9897081
Convert FromNameLoader to class. 2024-02-12 07:43:29 +01:00
Markus Reiter
8e04ab8b42
Fix type signature. 2024-02-12 07:14:28 +01:00
Markus Reiter
0211feebd7
Fix loading test fixtures. 2024-02-12 07:14:27 +01:00
Markus Reiter
6f28392d6e
Remove FromDefaultTapPathLoader and FromDefaultTapLoader. 2024-02-12 07:12:33 +01:00
Markus Reiter
d17aa66759
Avoid T.cast. 2024-02-12 07:12:32 +01:00
Markus Reiter
3e61e3b428
Stop following recursive tap migrations. 2024-02-10 15:07:31 +01:00
Markus Reiter
cb13f95928
Avoid T.cast. 2024-02-09 16:59:27 +01:00