Skip to content

Commit f689901

Browse files
committed
Merge 51814411-version-resolution to master
[Completes #51814411]
2 parents 2f811df + 38a8964 commit f689901

2 files changed

Lines changed: 15 additions & 11 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,9 +43,9 @@ def initialize(version, allow_wildcards = true)
4343
#
4444
# @return [Integer] A numerical representation of the comparisong between two instances
4545
def <=>(another)
46-
comparison = self[0] <=> another[0]
47-
comparison = self[1] <=> another[1] if comparison == 0
48-
comparison = self[2] <=> another[2] if comparison == 0
46+
comparison = self[0].to_i <=> another[0].to_i
47+
comparison = self[1].to_i <=> another[1].to_i if comparison == 0
48+
comparison = self[2].to_i <=> another[2].to_i if comparison == 0
4949
comparison = qualifier_compare(self[3].nil? ? '' : self[3], another[3].nil? ? '' : another[3]) if comparison == 0
5050

5151
comparison

spec/java_buildpack/util/version_resolver_spec.rb

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ module JavaBuildpack::Util
2121
describe VersionResolver do
2222

2323
VERSIONS = [
24-
'1.6.0_26',
25-
'1.6.0_27',
26-
'1.6.1_14',
27-
'1.7.0_19',
28-
'1.7.0_21',
29-
'1.8.0_M-7',
30-
'1.8.0_05',
31-
'2.0.0'
24+
'1.6.0_26',
25+
'1.6.0_27',
26+
'1.6.1_14',
27+
'1.7.0_19',
28+
'1.7.0_21',
29+
'1.8.0_M-7',
30+
'1.8.0_05',
31+
'2.0.0'
3232
]
3333

3434
it 'resolves the default version if no candidate is supplied' do
@@ -66,6 +66,10 @@ module JavaBuildpack::Util
6666
expect(VersionResolver.resolve('1.7.0_+', ['1.7.0_28', '1.7.0_28a']).to_s).to eq('1.7.0_28a')
6767
end
6868

69+
it 'should resolve versions numerically' do
70+
expect(VersionResolver.resolve('7.0.+', ['7.0.8', '7.0.40']).to_s).to eq('7.0.40')
71+
end
72+
6973
it 'should raise an exception when the major version is not numeric' do
7074
expect { VersionResolver.resolve('A', []) }.to raise_error(/Invalid/)
7175
end

0 commit comments

Comments
 (0)