From 1367ceeebad867badc3bde8917cd3638e0b0d4e7 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridnev Date: Thu, 12 Dec 2024 19:18:40 +0100 Subject: [PATCH] fix: display correct version when build version is not set - Added fallback to retrieve version from module build info when version is not provided via build flags --- cmd/version/version.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/version/version.go b/cmd/version/version.go index 51b6874..45bf2dc 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/qase-tms/qasectl/internal" "github.com/spf13/cobra" + "runtime/debug" ) func VersionCmd() *cobra.Command { @@ -13,6 +14,11 @@ func VersionCmd() *cobra.Command { DisableFlagParsing: true, Run: func(cmd *cobra.Command, args []string) { if internal.Version == "" { + info, ok := debug.ReadBuildInfo() + if ok && info.Main.Version != "(devel)" { + fmt.Println("Qase CLI " + info.Main.Version) + return + } fmt.Println("Qase CLI: version not set during build.") } else { fmt.Println("Qase CLI " + internal.Version)