Extend the allow/forbid of taps during formula installation to allow or
forbid the installation of taps themselves based on the values of the
`HOMEBREW_ALLOWED_TAPS` and `HOMEBREW_FORBIDDEN_TAPS` environment
variables.
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
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.
- Only two audits were using this: `audit_keg_only_reason` and `audit_text`,
and they weren't using any of its text processing methods, so there's little
reason to keep it around.
- The "`keg_only_reason` shouldn't contain 'HOMEBREW_PREFIX'" audit can easily
be replaced with a RuboCop since that's "just" text parsing.
- The "tests should invoke binaries with `bin/<command>`" audit had to stay as
a FormulaAudit because it requires accessing attributes about the Formula
like its name, aliases, which RuboCop can't get to, but it was easy to move the
singular "read the text in the file" line from `FormulaTextAuditor`.
Most users don't need the core taps to be installed locally but the
current message doesn't communicate that they're sometimes necessary
for local development. This just tweaks the message to be more
informative.
```console
$ brew tap homebrew/cask
Error: Tapping homebrew/cask is no longer typically necessary.
Add --force if you are sure you need it for local development.
```
livecheck is returning an `Unable to get versions` error for the
`ansible-lint`, `aws-sam-cli`, and `pyqt-builder` formulae. These use
the `Pypi` strategy without a `livecheck` block, so they use the
generated regex from the strategy. The `Pypi` strategy matches the
version from the tarball link on the pypi.org package page but this
fails for these packages because the formula's `stable` tarball uses
hyphens in the filename (e.g., `ansible-lint-...`) but the current
tarball filename uses underscores (e.g., `ansible_lint-...`).
This addresses the issue by updating the strategy regex to replace
[escaped] `-` or `_` characters in the package name with `[_-]`, so
the regex will match regardless of the delimiter used in the formula
filename.