File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
1919 "github.com/snowdreamtech/unirtm/internal/cli/output"
2020 "github.com/snowdreamtech/unirtm/internal/pkg/env"
2121 pkgHttp "github.com/snowdreamtech/unirtm/internal/pkg/http"
22+ "github.com/snowdreamtech/unirtm/internal/pkg/version"
2223 "github.com/spf13/cobra"
2324)
2425
@@ -299,11 +300,14 @@ func runSelfUpdate(cmd *cobra.Command, args []string) error {
299300 } else {
300301 spinner .Success (fmt .Sprintf ("Found release: %s" , releaseInfo .TagName ))
301302
302- // Version comparison with normalized tags (strip leading 'v')
303- if target == "latest" && normalizeVersion (current ) == normalizeVersion (releaseInfo .TagName ) {
304- output .Infof ("You are already using the latest version (%s)." , current )
305- if ! selfUpdateYes {
306- return nil
303+ // Version comparison: avoid downgrading if the current version is newer or equal
304+ if target == "latest" {
305+ cmp := version .CompareVersions (current , releaseInfo .TagName )
306+ if cmp >= 0 {
307+ output .Infof ("You are already using the latest version (%s)." , current )
308+ if ! selfUpdateYes {
309+ return nil
310+ }
307311 }
308312 }
309313
You can’t perform that action at this time.
0 commit comments