Skip to content

Commit a9ab9bc

Browse files
authored
Merge pull request #1188 from ActiveState/update-notavailable
Account for updates not being available
2 parents 5d2dec8 + e04a657 commit a9ab9bc

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

internal/runners/update/lock.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package update
22

33
import (
4-
"github.com/ActiveState/cli/internal/constants"
54
"github.com/ActiveState/cli/internal/errs"
65
"github.com/ActiveState/cli/internal/locale"
76
"github.com/ActiveState/cli/internal/output"
@@ -46,9 +45,14 @@ func (l *Lock) Run(params *LockParams) error {
4645
}
4746
channel := fetchChannel(defaultChannel, prefer)
4847

49-
_, info, err := fetchUpdater(constants.Version, channel)
50-
if err != nil {
51-
return errs.Wrap(err, "fetchUpdater failed")
48+
var version string
49+
if l.project.IsLocked() && channel == l.project.Branch() {
50+
version = l.project.Version()
51+
}
52+
53+
_, info, err := fetchUpdater(version, channel)
54+
if err != nil || info == nil {
55+
return errs.Wrap(err, "fetchUpdater failed, info: %v", info)
5256
}
5357

5458
err = projectfile.AddLockInfo(l.project.Source().Path(), channel, info.Version)

internal/runners/update/update.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ func (u *Update) Run(params *Params) error {
4848
return errs.Wrap(err, "fetchUpdater failed")
4949
}
5050

51+
if info == nil {
52+
u.out.Print(locale.Tl("update_uptodate", "You are already using the latest State Tool version available."))
53+
return nil
54+
}
55+
5156
if err = up.Run(u.out, false); err != nil {
5257
if os.IsPermission(errs.InnerError(err)) {
5358
return locale.WrapError(err, "err_update_failed_due_to_permissions", "Update failed due to permission error. You may have to re-run the command as a privileged user.")

0 commit comments

Comments
 (0)