Initial 'v' in versions should not be compared on (fixes #980)

This commit is contained in:
Jakob Borg
2014-11-17 18:49:51 +04:00
parent f66c7dc09c
commit 70d8903d3c
2 changed files with 8 additions and 0 deletions

View File

@@ -153,6 +153,10 @@ func CompareVersions(a, b string) int {
// Split a version into parts.
// "1.2.3-beta.2" -> []int{1, 2, 3}, []interface{}{"beta", 2}
func versionParts(v string) ([]int, []interface{}) {
if strings.HasPrefix(v, "v") || strings.HasPrefix(v, "V") {
// Strip initial 'v' or 'V' prefix if present.
v = v[1:]
}
parts := strings.SplitN(v, "+", 2)
parts = strings.SplitN(parts[0], "-", 2)
fields := strings.Split(parts[0], ".")