I ran `brew livecheck` today to check the packages in my watchlist
and realized that it wasn't checking one package because I had added
a trailing comment after the name (and `package # Comment` isn't a
valid package name). I thought we had added support for trailing
comments when we originally added comment support years back but I
must have been mistaken.
This adds support for trailing comments in livecheck watchlist files
as part of refactoring the watchlist line parsing logic to only use
one pass (instead of multiple `#map` and `#reject` calls). This
maintains the existing behavior, where blank lines and lines starting
with `#` are skipped, but does so in a more flexible manner. For
example, the existing logic wouldn't skip a comment line that has one
or more spaces before the `#` character but this new logic will
correctly skip it.
`brew bump` understands that some formulae/casks are skipped by
livecheck but it doesn't use this information to avoid doing
unnecessary or inappropriate work. This modifies related logic to not
fetch PR information or try to open a version bump PR if livecheck is
skipped. livecheck is our only source of version information these
days, so we can't try to version bump a package if we don't have
upstream version information.
This has been leading to an "Invalid usage: `--version` must not be
empty" error and this _should_ fix the issue under these particular
circumstances. There's still plenty of room for improvement in how
all of this is handled in bump but this is just a quick bug fix.
We sometimes see errors like "attempted to use a `Downloadable`
without a URL!" in the homebrew/cask autobump workflow log because
`bump-cask-pr` can simulate Linux even if a cask doesn't support it,
leading to this error. This is something that should be resolved in
the future once I finally wrap up my related work to detect OS/arch
requirements but this adds a simple guard to address this in the
interim time.
`HOMEBREW_FORCE_BREW_WRAPPER` can be used as a security/compliance
feature, but allowing it to be disabled by setting
`HOMEBREW_NO_FORCE_BREW_WRAPPER` leaves a pretty large hole in it that
allows it to be sidestepped.
Let's fix that by actually checking the path of the process that called
`brew`, and the verify that that path matches the configured value of
`HOMEBREW_NO_FORCE_BREW_WRAPPER`.
`ensure_formula_installed!` requires the `Formula` class to be loaded
before being called to work properly.
Let's guarantee that instead by implementing it as an instance method of
the `Formula` class.
See discussion at #20358.
This does the same as #20356 for `ensure_formula_installed!`. See
discussion at #20352.
Unfortunately, one must still `require "formula"` before using this
method because of the `returns(Formula)`, but tightening the type
signature is generally a good idea anyway.
Closes#20352.
Fixes
❯ HOMEBREW_BAT=1 brew cat xz
Error: uninitialized constant Kernel::Formula
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
/opt/homebrew/Library/Homebrew/extend/kernel.rb:445:in 'block in <module:Kernel>'
/opt/homebrew/Library/Homebrew/dev-cmd/cat.rb:33:in 'block in Homebrew::DevCmd::Cat#run'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/lib/ruby/3.4.0/fileutils.rb:241:in 'Dir.chdir'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.4.5/lib/ruby/3.4.0/fileutils.rb:241:in 'FileUtils#cd'
/opt/homebrew/Library/Homebrew/dev-cmd/cat.rb:29:in 'Homebrew::DevCmd::Cat#run'
/opt/homebrew/Library/Homebrew/brew.rb:113:in '<main>'
Please report this issue:
https://docs.brew.sh/Troubleshooting
This is really only used in Homebrew/core, so it should be safe to just
change `ref` here to `main`. Without this, `dispatch-build-bottle`
creates PRs that mistakenly target the `master` branch instead of the
`main` branch.