Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down