In some configurations, Sorbet gets upset by the `version.to_json` call
in `Library/Homebrew/version.rb`. This is because Sorbet's splat
support is lacking and it cannot handle the `*options` argument when it
does not know the size.
The regex to match Debian `orig` tarballs uses the standard regex for
versions like `1.2.3` but it won't match versions without a dot. The
`lcrack` formula uses a date-based version in the filename
(`lcrack_20040914.orig.tar.gz`) and `mkcue` uses a single number
(`mkcue_1.orig.tar.gz`), so we have to use a manual `version` in
these formulae.
This updates the regex to use the looser `NUMERIC_WITH_OPTIONAL_DOTS`
pattern, which will also match the aforementioned versions. I tested
this by checking versions of formulae before/after this change and
confirming that they remain the same after removing the `version`
calls from related formulae.
If you're trying to use `brew info --json=v2` to get an installed
version and figure out if it is outdated: you're going to have a bad
time with `auto_updates` casks because `installed_version` alone is not
enough to get the actually currently installed version of the app.
Instead, in these cases, try to read from `Info.plist` if there is one
and use that version.
While we're here, add a `blank?` method to `Version` so we can use it
for `present?` checks (making a `null?` `Version` object `blank?`).
Co-authored-by: Markus Reiter <me@reitermark.us>
The existing date version parsing regex only matches file names that
have a prefix (e.g., `ltopers-v2017-04-14.tar.gz`), so it doesn't
match files like `2023-09-28.tar.gz`. There are a handful of formulae
that have to manually specify the version as a result (e.g.,
`marksman`, `sqtop`, etc.). `bootloadhid` is also affected but that's
because the filename uses a dot as the prefix delimiter (e.g.,
`bootloadHID.2012-12-08.tar.gz`) and the regex only matches a hyphen.
This addresses these shortcomings by using `[._-]` as the prefix
delimiter and making it optional.
Co-authored-by: Markus Reiter <me@reitermark.us>
The existing date version parsing regex only matches file names that
have a prefix (e.g., `ltopers-v2017-04-14.tar.gz`), so it doesn't
match files like `2023-09-28.tar.gz`. There are a handful of formulae
that have to manually specify the version as a result (e.g.,
`marksman`, `sqtop`, etc.). `bootloadhid` is also affected but that's
because the filename uses a dot as the prefix delimiter (e.g.,
`bootloadHID.2012-12-08.tar.gz`) and the regex only matches a hyphen.
This addresses these shortcomings by using `[._-]` as the prefix
delimiter and making it optional.
We have no commands with Sorbet disabled and have had Sorbet enabled
for developers for a decent amount of time. As a result, we can enable
it for everyone who has run a developer command.
This also allows a bunch of `raise TypeError`s to be removed in favour
of relying on Sorbet here instead.