Skip to content

Commit 367101b

Browse files
stonedhiddeco
authored andcommitted
Only report version check when it can be
Signed-off-by: Stoned Elipot <stoned.elipot@gmail.com>
1 parent 408dc02 commit 367101b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

version/version.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,19 @@ func PrintVersion(c *cli.Context) {
1818
out := fmt.Sprintf("%s %s", c.App.Name, c.App.Version)
1919
if c.Bool("disable-version-check") {
2020
out += "\n"
21+
} else {upstreamVersion, err := RetrieveLatestVersionFromUpstream()
22+
if err != nil {
23+
out += fmt.Sprintf("\n[warning] failed to retrieve latest version from upstream: %v\n", err)
24+
}
25+
outdated, err := AIsNewerThanB(upstreamVersion, Version)
26+
if err != nil {
27+
out += fmt.Sprintf("\n[warning] failed to compare current version with latest: %v\n", err)
2128
} else {
22-
upstreamVersion, err := RetrieveLatestVersionFromUpstream()
23-
if err != nil {
24-
out += fmt.Sprintf("\n[warning] failed to retrieve latest version from upstream: %v\n", err)
25-
}
26-
outdated, err := AIsNewerThanB(upstreamVersion, Version)
27-
if err != nil {
28-
out += fmt.Sprintf("\n[warning] failed to compare current version with latest: %v\n", err)
29-
}
30-
if outdated {
31-
out += fmt.Sprintf("\n[info] sops %s is available, update with `go get -u github.com/getsops/sops/v3/cmd/sops`\n", upstreamVersion)
32-
} else {
33-
out += " (latest)\n"
34-
}
29+
if outdated {
30+
out += fmt.Sprintf("\n[info] sops %s is available, update with `go get -u github.com/getsops/sops/v3/cmd/sops`\n", upstreamVersion)
31+
} else {
32+
out += " (latest)\n"
33+
}
3534
}
3635
fmt.Fprintf(c.App.Writer, "%s", out)
3736
}

0 commit comments

Comments
 (0)