lib/upgrade: 0.x to 1.0 is a minor upgrade
This removes the special handling of minor versions as major when the actual major is zero, and adds the special case that upgrades from 0.x to 1.x are considered minor. 0.x to 2.x or 1.x to 2.x etc are still considered major. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4226
This commit is contained in:
committed by
Audrius Butkevicius
parent
3641c97667
commit
db1dc9985a
@@ -104,20 +104,26 @@ func CompareVersions(a, b string) Relation {
|
||||
for i := 0; i < minlen; i++ {
|
||||
if arel[i] < brel[i] {
|
||||
if i == 0 {
|
||||
// major version difference
|
||||
if arel[0] == 0 && brel[0] == 1 {
|
||||
// special case, v0.x is equivalent in majorness to v1.x.
|
||||
return Older
|
||||
}
|
||||
return MajorOlder
|
||||
}
|
||||
if i == 1 && arel[0] == 0 {
|
||||
return MajorOlder
|
||||
}
|
||||
// minor or patch version difference
|
||||
return Older
|
||||
}
|
||||
if arel[i] > brel[i] {
|
||||
if i == 0 {
|
||||
// major version difference
|
||||
if arel[0] == 1 && brel[0] == 0 {
|
||||
// special case, v0.x is equivalent in majorness to v1.x.
|
||||
return Newer
|
||||
}
|
||||
return MajorNewer
|
||||
}
|
||||
if i == 1 && arel[0] == 0 {
|
||||
return MajorNewer
|
||||
}
|
||||
// minor or patch version difference
|
||||
return Newer
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user