MCPcopy Index your code
hub / github.com/rilldata/rill / CheckVersion

Method CheckVersion

cli/pkg/cmdutil/update.go:21–57  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

19)
20
21func (h *Helper) CheckVersion(ctx context.Context) error {
22 // Check if build from source
23 if h.Version.Number == "" {
24 return nil
25 }
26
27 // Add a timeout
28 ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
29 defer cancel()
30
31 latestVersion, err := h.LatestVersion(ctx)
32 if err != nil {
33 return err
34 }
35
36 v1, err := version.NewVersion(h.Version.Number)
37 if err != nil {
38 return err
39 }
40
41 v2, err := version.NewVersion(latestVersion)
42 if err != nil {
43 // Set version as empty if any parse errors
44 _ = h.DotRill.SetVersion("")
45 return err
46 }
47
48 if v1.LessThan(v2) {
49 fmt.Printf("%s %s → %s\n\n",
50 color.YellowString("A new version of rill is available (run `rill upgrade`):"),
51 color.CyanString(h.Version.Number),
52 color.CyanString(latestVersion))
53 return nil
54 }
55
56 return nil
57}
58
59// LatestVersion returns the latest available version of Rill (cached for up to 24 hours).
60func (h *Helper) LatestVersion(ctx context.Context) (string, error) {

Callers 1

RunFunction · 0.95

Calls 3

LatestVersionMethod · 0.95
SetVersionMethod · 0.80
PrintfMethod · 0.80

Tested by

no test coverage detected