Sam Ford 5930880920
Gnome: Update default regex and version filtering
The `Gnome` strategy's default regex uses the `+` form of the standard
regex for matching versions like 1.2.3. However, with the switch to
the new version scheme, some packages had a release that omits a
minor and patch (i.e., `40` instead of `40.0`). The default regex
fails to match versions like this but the looser `*` form will match
both. [When creating regexes, we generally start with the `+` form
and only switch to the looser `*` form when it's necessary and
contextually-appropriate.]

This also updates the default version filtering logic that's applied
to versions using the old GNOME version scheme (below version 40).
Outside of the refactoring changes, this also filters out versions
where the patch number is 90+, as these are also unstable.
2022-06-13 18:17:56 -04:00

39 lines
1012 B
Ruby

# typed: false
# frozen_string_literal: true
require "livecheck/strategy/gnome"
describe Homebrew::Livecheck::Strategy::Gnome do
subject(:gnome) { described_class }
let(:gnome_url) { "https://download.gnome.org/sources/abc/1.2/abc-1.2.3.tar.xz" }
let(:non_gnome_url) { "https://brew.sh/test" }
let(:generated) {
{
url: "https://download.gnome.org/sources/abc/cache.json",
regex: /abc-(\d+(?:\.\d+)*)\.t/i,
}
}
describe "::match?" do
it "returns true for a GNOME URL" do
expect(gnome.match?(gnome_url)).to be true
end
it "returns false for a non-GNOME URL" do
expect(gnome.match?(non_gnome_url)).to be false
end
end
describe "::generate_input_values" do
it "returns a hash containing url and regex for a GNOME URL" do
expect(gnome.generate_input_values(gnome_url)).to eq(generated)
end
it "returns an empty hash for a non-GNOME URL" do
expect(gnome.generate_input_values(non_gnome_url)).to eq({})
end
end
end