Skip to content

Commit 17a6162

Browse files
author
Glyn Normington
committed
Merge 50968219- to master
[Completes #50968219]
2 parents b4c5660 + 997a666 commit 17a6162

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/java_buildpack/version_resolver.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ def <=>(another)
7676
self_qualifier = self[3].nil? ? '' : self[3]
7777
another_qualifier = another[3].nil? ? '' : another[3]
7878
i = 0
79-
until comparison != 0 || i == [self_qualifier.length, another_qualifier.length].max
79+
until comparison != 0 || i == [self_qualifier.length, another_qualifier.length].min
8080
comparison = char_compare(self_qualifier[i], another_qualifier[i])
8181
i += 1
8282
end
83+
comparison = self_qualifier.length <=> another_qualifier.length if comparison == 0
8384

8485
comparison
8586
end

spec/java_buildpack/version_resolver_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
expect(JavaBuildpack::VersionResolver.resolve('1.8.0_M-7', VERSIONS)).to eq('1.8.0_M-7')
6060
end
6161

62+
it 'should order qualifiers correctly' do
63+
expect(JavaBuildpack::VersionResolver.resolve('1.7.0_+', ['1.7.0_28', '1.7.0_28a'])).to eq('1.7.0_28a')
64+
end
65+
6266
it 'should raise an exception when the major version is not numeric' do
6367
expect { JavaBuildpack::VersionResolver.resolve('A', VERSIONS) }.to raise_error
6468
end

0 commit comments

Comments
 (0)