Fix versioncmp for ce edition

Signed-off-by: Stefan Scherer <scherer_stefan@icloud.com>
This commit is contained in:
Stefan Scherer
2017-06-09 12:41:36 +02:00
parent c604d46dc5
commit efe0ca5273
2 changed files with 4 additions and 2 deletions

View File

@@ -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.

View File

@@ -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 {