diff --git a/version.go b/version.go index 30454e1..dbd39e3 100644 --- a/version.go +++ b/version.go @@ -212,17 +212,11 @@ func comparePart(preSelf string, preOther string) int { // if a part is empty, we use the other to decide if preSelf == "" { - if otherNumeric { - return -1 - } - return 1 + return -1 } if preOther == "" { - if selfNumeric { - return 1 - } - return -1 + return 1 } if selfNumeric && !otherNumeric { diff --git a/version_test.go b/version_test.go index bd3534a..33f4c96 100644 --- a/version_test.go +++ b/version_test.go @@ -190,7 +190,9 @@ func TestComparePreReleases(t *testing.T) { {"3.0-alpha.3", "3.0-rc.1", -1}, {"3.0-alpha3", "3.0-rc1", -1}, {"3.0-alpha.1", "3.0-alpha.beta", -1}, - {"5.4-alpha", "5.4-alpha.beta", 1}, + {"5.4-alpha", "5.4-alpha.beta", -1}, + {"5.4-beta", "5.4-alpha.beta", 1}, + {"5.4-beta.2", "5.4-alpha.beta", 1}, {"v1.2-beta.2", "v1.2-beta.2", 0}, {"v1.2-beta.1", "v1.2-beta.2", -1}, {"v3.2-alpha.1", "v3.2-alpha", 1},