Skip to content

Commit 8e145f0

Browse files
committed
Fixed buggy weaver version output.
`weaver version` is supposed to print out the weaver module version, something like: ``` $ weaver version weaver v0.15.0 ``` Previously, we used [`runtime.ReadBuildInfo`][ReadBuildInfo] to read the version of the main module. However, I realized that this version was always the string `(devel)`. At first, I thought the version was `(devel)` when on a non-tagged commit, but later realized that it is literally always `(devel)`: golang/go#29228. I did some Googling to figure out how to print out the current module version, but it seems impossible? This PR gives up and sticks with showing the git commit. It's not as clear, but you can look up the commit in the repo history to find the module version. [ReadBuildInfo]: https://pkg.go.dev/runtime/debug#ReadBuildInfo
1 parent e7a0ddf commit 8e145f0

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

runtime/tool/version.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ func VersionCmd(tool string) *Command {
3535
Fn: func(context.Context, []string) error {
3636
deployerAPI := fmt.Sprintf("%d.%d.%d", version.Major, version.Minor, version.Patch)
3737
codegenAPI := fmt.Sprintf("%d.%d.0", codegen.Major, codegen.Minor)
38-
release := "?"
3938
commit := "?"
4039
if info, ok := debug.ReadBuildInfo(); ok {
41-
release = info.Main.Version
4240
for _, setting := range info.Settings {
4341
// vcs.revision stores the commit at which the weaver tool
4442
// was built. See [1] for more information.
@@ -50,9 +48,9 @@ func VersionCmd(tool string) *Command {
5048
}
5149
}
5250
}
53-
fmt.Printf("%s %s\n", tool, release)
54-
fmt.Printf("target: %s/%s\n", runtime.GOOS, runtime.GOARCH)
51+
fmt.Printf("tool: %s\n", tool)
5552
fmt.Printf("commit: %s\n", commit)
53+
fmt.Printf("target: %s/%s\n", runtime.GOOS, runtime.GOARCH)
5654
fmt.Printf("deployer API: %s\n", deployerAPI)
5755
fmt.Printf("codegen API: %s\n", codegenAPI)
5856
return nil

0 commit comments

Comments
 (0)