brew icon indicating copy to clipboard operation
brew copied to clipboard

Fix cask source file path loading issues

Open apainintheneck opened this issue 1 month ago • 1 comments

  • [x] Have you followed the guidelines in our Contributing document?
  • [x] Have you checked to ensure there aren't other open Pull Requests for the same change?
  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [x] Have you written new tests for your changes? Here's an example.
  • [x] Have you successfully run brew style with your changes locally?
  • [x] Have you successfully run brew typecheck with your changes locally?
  • [ ] Have you successfully run brew tests with your changes locally?

Fixes #17226

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.

  1. 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.

apainintheneck avatar May 07 '24 06:05 apainintheneck

The error message now looks like this:

Error: These formulae and casks are not in any locally installed taps!

- discord
- iterm2
- visual-studio-code
- zstd

You may need to run `brew tap` to install additional taps.

apainintheneck avatar May 08 '24 04:05 apainintheneck

Thanks @apainintheneck!

MikeMcQuaid avatar May 09 '24 07:05 MikeMcQuaid