(ctx context.DnoteCtx)
| 85 | } |
| 86 | |
| 87 | func 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 |
| 111 | func Check(ctx context.DnoteCtx) error { |
no test coverage detected