X Tutup
Skip to content

Commit efe0ca5

Browse files
committed
Fix versioncmp for ce edition
Signed-off-by: Stefan Scherer <scherer_stefan@icloud.com>
1 parent c604d46 commit efe0ca5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

libmachine/versioncmp/compare.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ func compare(v1, v2 string) int {
2929
// presence of the "ce" string in the version string) are "less than"
3030
// any community edition release (first occuring in March 2017).
3131
if strings.Contains(v1, ceEdition) && !strings.Contains(v2, ceEdition) {
32-
return -1
32+
return 1
3333
}
3434
if !strings.Contains(v1, ceEdition) && strings.Contains(v2, ceEdition) {
35-
return 1
35+
return -1
3636
}
3737

3838
// Without this tag, both are pre-CE versions.

libmachine/versioncmp/compare_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ func TestCompare(t *testing.T) {
3333
{"17.03.0-ce", "17.06.0-ce", -1},
3434
{"17.03.0-ce-rc2", "17.03.0-ce-rc1", 1},
3535
{"17.03.0-ce-rc1", "18.03.0-ce-rc1", -1},
36+
{"17.06.0-ce-rc2", "1.12.0", 1},
37+
{"1.12.0", "17.06.0-ce-rc2", -1},
3638
}
3739

3840
for _, tc := range cases {

0 commit comments

Comments
 (0)
X Tutup