Skip to content

Commit

Permalink
Fix versioncmp for ce edition
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Scherer <[email protected]>
  • Loading branch information
StefanScherer committed Jun 9, 2017
1 parent c604d46 commit efe0ca5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libmachine/versioncmp/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ func compare(v1, v2 string) int {
// presence of the "ce" string in the version string) are "less than"
// any community edition release (first occuring in March 2017).
if strings.Contains(v1, ceEdition) && !strings.Contains(v2, ceEdition) {
return -1
return 1
}
if !strings.Contains(v1, ceEdition) && strings.Contains(v2, ceEdition) {
return 1
return -1
}

// Without this tag, both are pre-CE versions.
Expand Down
2 changes: 2 additions & 0 deletions libmachine/versioncmp/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func TestCompare(t *testing.T) {
{"17.03.0-ce", "17.06.0-ce", -1},
{"17.03.0-ce-rc2", "17.03.0-ce-rc1", 1},
{"17.03.0-ce-rc1", "18.03.0-ce-rc1", -1},
{"17.06.0-ce-rc2", "1.12.0", 1},
{"1.12.0", "17.06.0-ce-rc2", -1},
}

for _, tc := range cases {
Expand Down

0 comments on commit efe0ca5

Please sign in to comment.