Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51301d9

Browse files
committed
fix versions
1 parent 54cb664 commit 51301d9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

buildinfo/buildinfo.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package buildinfo
33
import (
44
"fmt"
55
"runtime/debug"
6+
"strings"
67
"sync"
78
"time"
89

@@ -58,7 +59,9 @@ func Version() string {
5859
// disregarded. If it detects that either version is a developer build it
5960
// returns true.
6061
func VersionsMatch(v1, v2 string) bool {
61-
if semver.Prerelease(v1) == "-devel" || semver.Prerelease(v2) == "-devel" {
62+
// Developer versions are disregarded...hopefully they know what they are
63+
// doing.
64+
if strings.HasPrefix(v1, develPrefix) || strings.HasPrefix(v2, develPrefix) {
6265
return true
6366
}
6467

cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ to download the appropriate version run 'curl -L https://coder.com/install.sh |
384384
if !buildinfo.VersionsMatch(clientVersion, info.Version) {
385385
warn := cliui.Styles.Warn.Copy().Align(lipgloss.Left)
386386
// Trim the leading 'v', our install.sh script does not handle this case well.
387-
_, _ = fmt.Fprintf(cmd.OutOrStdout(), warn.Render(fmtWarningText), clientVersion, info.Version, info.TrimmedVersion()[1:])
387+
_, _ = fmt.Fprintf(cmd.OutOrStdout(), warn.Render(fmtWarningText), clientVersion, info.Version, strings.TrimPrefix(info.CanonicalVersion(), "v"))
388388
_, _ = fmt.Fprintln(cmd.OutOrStdout())
389389
}
390390

codersdk/buildinfo.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ type BuildInfoResponse struct {
1919
Version string `json:"version"`
2020
}
2121

22-
// TrimmedVersion trims build information from the version.
22+
// CanonicalVersion trims build information from the version.
2323
// E.g. 'v0.7.4-devel+11573034' -> 'v0.7.4'.
24-
func (b BuildInfoResponse) TrimmedVersion() string {
25-
trimmed := strings.ReplaceAll(b.Version, "-devel", "+devel")
24+
func (b BuildInfoResponse) CanonicalVersion() string {
25+
// We do a little hack here to massage the string into a form
26+
// that works well with semver.
27+
trimmed := strings.ReplaceAll(b.Version, "-devel+", "+devel-")
2628
return semver.Canonical(trimmed)
2729
}
2830

0 commit comments

Comments
 (0)