fix(updater): compare the recorded version to the tag without the prefix
Test / test (push) Successful in 7m37s

This commit is contained in:
2026-09-29 10:56:29 +02:00
parent f8ed33df83
commit d2b6f0099b
2 changed files with 51 additions and 0 deletions
+11
View File
@@ -122,8 +122,19 @@ func fetchBounded(url string, limit int64) ([]byte, error) {
return body, nil
}
// trimVersionPrefix removes the "v" the toolchain records with, so a
// recorded version ("v1.2.3", or a pseudo-version "v0.0.0-…") compares
// against release tags, which CheckLatest already reports without it.
func trimVersionPrefix(v string) string {
return strings.TrimPrefix(v, "v")
}
// CompareVersions compares two dotted versions numerically per part.
// Either side may carry the leading "v" of a recorded version or of a
// tag; the shapes compare equal, which is what keeps an installation
// running v1.0.0 from being offered an update to 1.0.0.
func CompareVersions(a, b string) int {
a, b = trimVersionPrefix(a), trimVersionPrefix(b)
as, bs := strings.Split(a, "."), strings.Split(b, ".")
for i := 0; i < len(as) || i < len(bs); i++ {
av, bv := part(as, i), part(bs, i)