MCPcopy Create free account
hub / github.com/dnote/dnote / checkVersion

Function checkVersion

pkg/cli/upgrade/upgrade.go:87–108  ·  view source on GitHub ↗
(ctx context.DnoteCtx)

Source from the content-addressed store, hash-verified

85}
86
87func checkVersion(ctx context.DnoteCtx) error {
88 log.Infof("current version is %s\n", ctx.Version)
89
90 // Fetch the latest version
91 gh := github.NewClient(nil)
92 latestTag, err := fetchLatestStableTag(gh, 1)
93 if err != nil {
94 return errors.Wrap(err, "fetching the latest stable release")
95 }
96
97 // releases are tagged in a form of cli-v1.0.0
98 latestVersion := latestTag[5:]
99 log.Infof("latest version is %s\n", latestVersion)
100
101 if latestVersion == ctx.Version {
102 log.Success("you are up-to-date\n\n")
103 } else {
104 log.Infof("to upgrade, see https://github.com/dnote/dnote\n")
105 }
106
107 return nil
108}
109
110// Check triggers update if needed
111func Check(ctx context.DnoteCtx) error {

Callers 1

CheckFunction · 0.85

Calls 3

InfofFunction · 0.92
SuccessFunction · 0.92
fetchLatestStableTagFunction · 0.85

Tested by

no test coverage detected