Skip to content

Commit ecb17c9

Browse files
committed
cmd/cue: revert version string change
In 370fac9 we slightly changed the way that the cue version string is determined. For builds of cmd/cue that resolve the cuelang.org/go as a dependency, the only noticeable change would have been the inclusion of the sum of that module (which is harmless, but arguably superfluous). However for development builds the change meant that we were left with "devel" as the version string: cue version devel linux/amd64 Rather than the now-default +$commit(-dirty)? Go default: cue version +eb18b74c linux/amd64 We need/want the latter, hence we revert this particular change, adding a more explicit comment that the use of the ldflags mechanism to set the version string is legacy. Signed-off-by: Paul Jolly <paul@myitcv.io> Change-Id: I26aed99031921a2d32e0fe94a78d9a73089c75c4 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/521406
1 parent 370fac9 commit ecb17c9

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

cmd/cue/cmd/version.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,26 @@ func newVersionCmd(c *Command) *cobra.Command {
3232
return cmd
3333
}
3434

35+
const (
36+
defaultVersion = "devel"
37+
)
38+
39+
// version be set by a builder using
40+
// -ldflags='-X cuelang.org/go/cmd/cue/cmd.version=<version>'.
41+
// However, people should prefer building via a mechanism which
42+
// resolves cuelang.org/go as a dependency (and not the main
43+
// module), in which case the version information is determined
44+
// from the *debug.BuildInfo (see below). So this mechanism is
45+
// really considered legacy.
46+
var (
47+
version = defaultVersion
48+
)
49+
3550
func runVersion(cmd *Command, args []string) error {
3651
w := cmd.OutOrStdout()
37-
var version = "devel"
38-
if bi, ok := debug.ReadBuildInfo(); ok && bi.Main.Sum != "" {
39-
version = fmt.Sprintf("%s (%s)", bi.Main.Version, bi.Main.Sum)
52+
if bi, ok := debug.ReadBuildInfo(); ok && version == defaultVersion {
53+
// No specific version provided via version
54+
version = bi.Main.Version
4055
}
4156
fmt.Fprintf(w, "cue version %v %s/%s\n",
4257
version,

0 commit comments

Comments
 (0)