Skip to content

Commit 70654ae

Browse files
author
Glyn Normington
committed
Extend version qualifier syntax
Allow version qualifiers to container periods ('.') to support qualifiers such as are found in Spring Boot CLI versions. [#54204032]
1 parent 8b85a2f commit 70654ae

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/java_buildpack/util/tokenized_version.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def initialize(version, allow_wildcards = true)
4343

4444
# Compare this to another array
4545
#
46-
# @return [Integer] A numerical representation of the comparisong between two instances
46+
# @return [Integer] A numerical representation of the comparison between two instances
4747
def <=>(other)
4848
comparison = self[0].to_i <=> other[0].to_i
4949
comparison = self[1].to_i <=> other[1].to_i if comparison == 0
@@ -62,7 +62,7 @@ def to_s # rubocop:disable TrivialAccessors
6262

6363
private
6464

65-
COLLATING_SEQUENCE = ['-'] + ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
65+
COLLATING_SEQUENCE = ['-', '.'] + ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
6666

6767
def char_compare(c1, c2)
6868
COLLATING_SEQUENCE.index(c1) <=> COLLATING_SEQUENCE.index(c2)
@@ -134,7 +134,7 @@ def valid_major_minor_or_micro(major_minor_or_micro)
134134
end
135135

136136
def valid_qualifier(qualifier)
137-
qualifier.nil? || qualifier.empty? || qualifier =~ /^[-a-zA-Z\d]*$/ || qualifier =~ /^\+$/
137+
qualifier.nil? || qualifier.empty? || qualifier =~ /^[-\.a-zA-Z\d]*$/ || qualifier =~ /^\+$/
138138
end
139139
end
140140

spec/java_buildpack/util/tokenized_version_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ module JavaBuildpack::Util
4444
expect(TokenizedVersion.new('1.7.0_28a')).to be > TokenizedVersion.new('1.7.0_28')
4545
end
4646

47+
it 'should accept a qualifier with embedded periods and hyphens' do
48+
TokenizedVersion.new('0.5.0_BUILD-20120731.141622-16')
49+
end
50+
4751
it 'should raise an exception when the major version is not numeric' do
4852
expect { TokenizedVersion.new('A') }.to raise_error(/Invalid/)
4953
end

0 commit comments

Comments
 (0)