186 Commits

Author SHA1 Message Date
Bo Anderson
923be69785
Phase out using cgi library 2025-05-13 01:33:14 +01:00
Douglas Eichelberger
0a8c8e2c50 Fix test 2025-02-17 19:11:48 -08:00
Douglas Eichelberger
8763fb6d29 Resolve rubocop violations 2025-02-17 18:56:31 -08:00
Douglas Eichelberger
791ff3ac75 Add rubocop exclusion 2024-08-19 09:56:50 -07:00
Douglas Eichelberger
fb2fdc5249 Minor type safety improvements 2024-08-18 18:16:39 -07:00
Mike McQuaid
be01b6ea64
version: use T.unsafe for https://srb.help/7019
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.
2024-07-25 12:14:06 +01:00
Sam Ford
2cd95d482d
version: loosen Debian orig tarball regex
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.
2024-07-24 11:39:09 -04:00
Bo Anderson
1962a37e94
version: enable strict typing 2024-06-11 23:03:53 +01:00
Mike McQuaid
222fe8ef0b
Homebrew 4.3.0 deprecation/disable/removals.
The usual pass of deprecating/disabling/removing code for the next
minor Homebrew release.
2024-05-07 12:18:04 +01:00
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
caf87c0336
Warn about undocumented non-private APIs. 2024-05-01 11:35:20 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Markus Reiter
c76170a456
Hide #to_s in docs. 2024-04-26 14:04:55 +02:00
Markus Reiter
fe4ef62aa9
Hide #inspect in docs. 2024-04-26 13:20:05 +02:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Mike McQuaid
03e583e746
cask: read bundle version from Info.plist when sensible.
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>
2024-03-06 15:52:16 +00:00
Issy Long
f682147598
Fix RuboCop Style/RedundantFreeze offenses 2024-01-18 22:20:01 +00:00
Bo Anderson
b42256d286
Deprecate, disable & delete code for Homebrew 4.2.0 2023-12-07 23:42:13 +00:00
Sam Ford
2298b74fed
Version: Improve date version parsing
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>
2023-10-07 16:37:23 -04:00
Francois-Xavier Coudert
748f060e1b Revert "Version: Improve date version parsing"
This reverts commit 7626bdd1fd84cc5f70c4cb9f7bdf323bb771cf59.
2023-10-04 19:56:21 +02:00
Sam Ford
7626bdd1fd
Version: Improve date version parsing
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.
2023-10-04 11:58:25 -04:00
Mike McQuaid
8775465872
Enable Sorbet after running a developer command
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.
2023-09-02 08:39:28 -04:00
Douglas Eichelberger
33d9dc63b0 Fix type errors when HOMEBREW_SORBET_RUNTIME=1 2023-07-18 10:22:51 -07:00
Mike McQuaid
7da934f7e2
Deprecate/disable/delete code.
The next release after this is merged will be 4.1.0.

Co-authored-by: Markus Reiter <me@reitermark.us>
2023-07-06 16:56:20 +01:00
Markus Reiter
5c9c089b68
Improve #to_str and #to_json for Version::NULL. 2023-05-11 19:16:42 +02:00
Markus Reiter
8274920217
Rename OS::Mac::Version to MacOSVersion. 2023-05-09 05:08:38 +02:00
Markus Reiter
4bbf120630
Add note about Version constructor. 2023-05-09 01:13:55 +02:00
Markus Reiter
fe19ddc3a7
Remove Version#empty?. 2023-05-09 01:13:55 +02:00
Markus Reiter
a1efaf1864
Merge HeadVersion and NullVersion into Version. 2023-05-09 01:13:54 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
c0092c2fd2 Move and re-namespace HeadVersion 2023-04-04 18:14:54 -07:00
Douglas Eichelberger
0ca4f7eebb Add Version#compare 2023-04-04 18:14:54 -07:00
Issy Long
60d93310af
rubocop: Drop "a" and "b" from Naming/MethodParameterName allowlist 2023-03-11 00:17:28 +00:00
Carlo Cabrera
93fd448c6c
version: fix bad regexps in version parsers
The character class `[.-v]` is interpreted as all the characters between
`.` and `v`, which is clearly not what is intended here.

Here's an example of what this fixes. Before:

    ❯ brew ruby -e 'puts Version.detect("https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0-rc1/llvm-project-16.0.0rc1.src.tar.xz")'
    6.0.0rc1

After:

    ❯ brew ruby -e 'puts Version.detect("https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0-rc1/llvm-project-16.0.0rc1.src.tar.xz")'
    16.0.0rc1

The problem here is that `1` is a match for `/[.-v]/`.

    ❯ brew ruby -e 'puts /[.-v]/.match("1")'
    1
2023-02-01 10:48:45 +08:00
Bo Anderson
24717a8ac3
version: tokenize prior to freezing 2022-06-02 03:25:55 +01:00
Bo Anderson
cee86846ce
Fix Sorbet violations. 2021-08-06 14:03:00 +01:00
EricFromCanada
5519a0b379
version: check for both cases in suffix 2021-07-16 08:28:15 -04:00
Sam Ford
d4c15a6d9d
Version: Add parser for hyphenated filenames 2021-06-16 14:16:57 -04:00
nandahkrishna
8e5451df2f
style: use parentheses for assignment in conditions 2021-02-12 18:33:37 +05:30
Bo Anderson
71d81a8611 version: handle subclasses in major_minor and major_minor_patch 2021-02-09 18:35:22 +00:00
Seeker
35f857e38f version: rename more regex constants 2021-01-28 16:59:51 -08:00
Seeker
c5d3b9ae3e version: rename regex constants 2021-01-28 16:42:44 -08:00
Seeker
2e6e38ec4d version: rename ALPHA_SUFFIX to PREREL_SUFFIX 2021-01-28 16:41:49 -08:00
Seeker
a52959d5d2 version: replace [-.vV] with [.-vV] in regexes 2021-01-28 16:41:49 -08:00
Seeker
fc7c243471 version: add constants for regexes 2021-01-28 16:41:49 -08:00
Seeker
d9e8a34d3b version: replace [.] with \. in regex 2021-01-28 16:41:49 -08:00
Seeker
f76bf240cd version: replace [-_] with [_-] in regexes 2021-01-28 16:41:49 -08:00
Seeker
e1d68cf1eb version: make [._-] consistent in regexes 2021-01-28 16:41:49 -08:00
Seeker
acdb05dbcf
Merge pull request #10407 from SeekingMeaning/version-public-api
version: mark methods as public
2021-01-25 18:50:08 -08:00
Seeker
0a0f435a88
Merge pull request #10378 from SeekingMeaning/version-regexes
version: add new `Version::Parser` class
2021-01-25 09:24:42 -08:00