Allow the ability for a system administrator to use
`HOMEBREW_BREW_WRAPPER` and `HOMEBREW_FORCE_BREW_WRAPPER` variables to
enforce the usage of a particular `brew` command for non-trivial (e.g.
`brew --prefix` is considered trivial, it doesn't need to write to the
prefix) Homebrew commands.
This also introduces a `HOMEBREW_ORIGINAL_BREW_FILE` variable for some
internal usage; `HOMEBREW_BREW_FILE` was being used internally for
both "how should we shell out to Homebrew" and "what should we use
to check permissions on Homebrew". `HOMEBREW_ORIGINAL_BREW_FILE` is
now used just for the latter case.
Inspired by conversation in
https://github.com/Homebrew/homebrew-bundle/pull/1551 which suggested
this was worth fixing in wider than just `brew bundle`.
On Linux HOMEBREW_CACHE may be set to `$HOME/.cache/Homebrew`. Some
systems, like Fedora Silverblue, have `/home` set up to be a symbolic
link to `/var/home`. While Homebrew generally seems to work fine on
Fedora Silverblue, rubocop causes the `brew style` command to emit
a lot of warnings because of the symbolic link[1]. This can be resolved
by looking up the real path of HOMEBREW_CACHE before passing it to rubocop.
[1] https://github.com/rubocop/rubocop/issues/6228
Co-authored-by: Bo Anderson <mail@boanderson.me>
- 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
```
- start running this check again
- check the `docs` basename correctly
- use a different name (to a symlink) for the docs rubocop
configuration so that path relativity is done correctly:
https://docs.rubocop.org/rubocop/configuration.html#path-relativity
- add more wildcards to fix docs rubocop exclusions
`brew style` tap support was broken in 7d0ac4d (#17357), so now
something like `brew style homebrew/core` exits without checking
anything. This happens because the new file-handling logic doesn't
do anything with a tap path. Previously, a tap path would be added
to `ruby_files` but now it isn't added to any of the arrays of files
to check.
This fixes the issue by adding some logic to add the path to the
`ruby_files` array if it's a tap.
It feels nice to also be running this as part of `brew style` checks
and, indirectly, `brew test-bot` tap syntax checks.
Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
We already do this for deprecations but these may make warnings
and errors from Homebrew easier to spot in GitHub Actions logs.
While we're here, cleanup other cases that should have used
`GitHub::Actions::Annotation` but didn't and provide some helpers and
tweaks there necessary for our use case here.
- Call `Homebrew.install_bundler_gems!` as early as possible
- Always call `Homebrew.install_bundler_gems!` in `dev-cmd` rather than
in `Library/Homebrew` helpers method (to ensure we don't accidentally
call this for non-dev-cmd commands)
- Yes, we have yet another `.rubocop.yml` but in-line exclusions in
`<span class="display:none;">` in the Markdown seemed more ugly.
- This needed tweaks to `brew style` to make it read the new config
file when we're scanning docs.