mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
Initial 'v' in versions should not be compared on (fixes #980)
This commit is contained in:
parent
f66c7dc09c
commit
70d8903d3c
@ -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], ".")
|
||||
|
@ -42,6 +42,10 @@ var testcases = []struct {
|
||||
{"1.0.0+45", "1.0.0+23-dev-foo", 0},
|
||||
{"1.0.0-beta.23+45", "1.0.0-beta.23+23-dev-foo", 0},
|
||||
{"1.0.0-beta.3+99", "1.0.0-beta.24+0", -1},
|
||||
|
||||
{"v1.1.2", "1.1.2", 0},
|
||||
{"v1.1.2", "V1.1.2", 0},
|
||||
{"1.1.2", "V1.1.2", 0},
|
||||
}
|
||||
|
||||
func TestCompareVersions(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user