fix(core-agent): classify prerelease versions correctly

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Virgil 2026-04-01 22:01:47 +00:00
parent 452c4a27c7
commit fdbf7f7e4d
2 changed files with 6 additions and 4 deletions

View file

@ -2,7 +2,10 @@
package main package main
import agentpkg "dappco.re/go/agent" import (
agentpkg "dappco.re/go/agent"
core "dappco.re/go/core"
)
// agentpkg.Version = "0.15.0" // agentpkg.Version = "0.15.0"
// updateChannel() // "stable" // updateChannel() // "stable"
@ -10,7 +13,7 @@ func updateChannel() string {
switch { switch {
case agentpkg.Version == "" || agentpkg.Version == "dev": case agentpkg.Version == "" || agentpkg.Version == "dev":
return "dev" return "dev"
case agentpkg.Version != "" && (agentpkg.Version[len(agentpkg.Version)-1] >= 'a'): case core.Contains(agentpkg.Version, "-"):
return "prerelease" return "prerelease"
default: default:
return "stable" return "stable"

View file

@ -43,8 +43,7 @@ func TestUpdate_UpdateChannelNumericSuffix_Ugly(t *testing.T) {
t.Cleanup(func() { t.Cleanup(func() {
agentpkg.Version = "" agentpkg.Version = ""
}) })
// Ends in '1' which is < 'a', so stable assert.Equal(t, "prerelease", updateChannel())
assert.Equal(t, "stable", updateChannel())
} }
func TestUpdate_ApplicationVersion_Good(t *testing.T) { func TestUpdate_ApplicationVersion_Good(t *testing.T) {