diff --git a/internal/releaseupdate/github.go b/internal/releaseupdate/github.go index a9dae4916..9135d4ab4 100644 --- a/internal/releaseupdate/github.go +++ b/internal/releaseupdate/github.go @@ -193,9 +193,14 @@ func installable(r githubRelease) string { } // ReleaseVersion is the release a build was cut from: a git-describe build -// ("1.55.0-218-gabc123") is the same release as its tag. +// ("1.55.0-218-gabc123") is the same release as its tag. A build that names no +// release ("dev") has none, so nothing can be judged newer than it. func ReleaseVersion(version string) string { - return buildSuffix.ReplaceAllString(version, "") + version = buildSuffix.ReplaceAllString(version, "") + if !semver.IsValid("v" + strings.TrimPrefix(version, "v")) { + return "" + } + return version } // installedAgent is the image the installer last switched to, recorded in a diff --git a/internal/webui/api_version_test.go b/internal/webui/api_version_test.go index c53863826..dac258d06 100644 --- a/internal/webui/api_version_test.go +++ b/internal/webui/api_version_test.go @@ -18,6 +18,7 @@ func TestVersionStatusFor(t *testing.T) { {"running a different release", "1.55.0", "1.54.3", "1.55.0", true, statusDrift}, {"older release installed", "1.54.3", "1.54.3", "1.55.0", true, statusUpdateAvailable}, {"nothing running reported", "1.55.0", "", "1.55.0", false, statusUnknown}, + {"development build", releaseupdate.ReleaseVersion("dev+5eeb29955d2a"), "dev+5eeb29955d2a", "1.55.0", true, statusUnknown}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {