Skip to content

Commit

Permalink
Merge pull request dependabot#4257 from zbynek/underscore-numeric-token
Browse files Browse the repository at this point in the history
Treat tokens after underscore as numeric if possible
  • Loading branch information
jurre authored Sep 27, 2021
2 parents cf19623 + dcd5243 commit a5cc5a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions gradle/lib/dependabot/gradle/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Version < Gem::Version
NULL_VALUES = %w(0 final ga).freeze
PREFIXED_TOKEN_HIERARCHY = {
"." => { qualifier: 1, number: 4 },
"-" => { qualifier: 2, number: 3 }
"-" => { qualifier: 2, number: 3 },
"_" => { qualifier: 2, number: 3 }
}.freeze
NAMED_QUALIFIERS_HIERARCHY = {
"a" => 1, "alpha" => 1,
Expand Down Expand Up @@ -132,7 +133,7 @@ def convert_dates(version, other_version)
end

def split_into_prefixed_tokens(version)
".#{version}".split(/(?=[\-\.])/)
".#{version}".split(/(?=[_\-\.])/)
end

def pad_for_comparison(prefixed_tokens, other_prefixed_tokens)
Expand Down
6 changes: 6 additions & 0 deletions gradle/spec/dependabot/gradle/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,12 @@
it { is_expected.to eq(1) }
end

context "numeric token after underscore" do
let(:version) { described_class.new("1.0.0_100") }
let(:other_version) { described_class.new("1.0.0_99") }
it { is_expected.to eq(1) }
end

context "null values (again)" do
let(:version) { described_class.new("1-sp-1") }
let(:other_version) { described_class.new("1-ga-1") }
Expand Down

0 comments on commit a5cc5a8

Please sign in to comment.