parent
fcfa007cec
commit
8c073bf45f
|
|
@ -44,6 +44,7 @@ require (
|
|||
connectrpc.com/connect v1.18.1 // indirect
|
||||
connectrpc.com/otelconnect v0.7.2 // indirect
|
||||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/MicahParks/jwkset v0.9.5 // indirect
|
||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
|
||||
|
|
|
|||
|
|
@ -80,6 +80,8 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEK
|
|||
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
|
||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/MicahParks/jwkset v0.7.0 h1:CXWuiYBk5NuTl+N/3UI3UcYNH79yWuKAZWZkc/y+7Ok=
|
||||
github.com/MicahParks/jwkset v0.7.0/go.mod h1:fVrj6TmG1aKlJEeceAz7JsXGTXEn72zP1px3us53JrA=
|
||||
github.com/MicahParks/jwkset v0.9.5 h1:/baA2n7RhO7nRIe1rx4ZX1Opeq+mwDuuWi2myDZwqnA=
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
config "github.com/OliveTin/OliveTin/internal/config"
|
||||
"github.com/OliveTin/OliveTin/internal/installationinfo"
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/Masterminds/semver"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io"
|
||||
"net/http"
|
||||
|
|
@ -55,11 +56,28 @@ func parseVersion(input []byte) string {
|
|||
if installationinfo.Build.Version == versionMap.Latest {
|
||||
return "none"
|
||||
} else {
|
||||
return versionMap.Latest
|
||||
return parseIfVersionIsLater(installationinfo.Build.Version, versionMap.Latest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parseIfVersionIsLater(currentString string, latestString string) string {
|
||||
currentVersion, errCurrent := semver.NewVersion(currentString)
|
||||
latestVersion, errLatest := semver.NewVersion(latestString)
|
||||
|
||||
if errCurrent != nil || errLatest != nil {
|
||||
log.Warnf("Version parse failure: %v %v", errCurrent, errLatest)
|
||||
|
||||
return "version-parse-failure"
|
||||
}
|
||||
|
||||
if latestVersion.GreaterThan(currentVersion) {
|
||||
return latestString
|
||||
}
|
||||
|
||||
return "none"
|
||||
}
|
||||
|
||||
func doRequest() string {
|
||||
req, err := http.NewRequest("GET", "http://update-check.olivetin.app/versions.json", nil)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package updatecheck
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestVersionLater(t *testing.T) {
|
||||
assert.Equal(t, "none", parseIfVersionIsLater("1.0.0", "1.0.0"))
|
||||
assert.Equal(t, "1.1.1", parseIfVersionIsLater("1.0.0", "1.1.1"))
|
||||
assert.Equal(t, "none", parseIfVersionIsLater("2.0.0", "1.10.1"))
|
||||
assert.Equal(t, "version-parse-failure", parseIfVersionIsLater("1.0.0", "1.2.3.4"))
|
||||
assert.Equal(t, "version-parse-failure", parseIfVersionIsLater("asdf", "foobar"))
|
||||
}
|
||||
Loading…
Reference in New Issue