Skip to content

Commit

Permalink
fix: display correct version when build version is not set
Browse files Browse the repository at this point in the history
- Added fallback to retrieve version from module build info when version is not provided via build flags
  • Loading branch information
gibiw committed Dec 12, 2024
1 parent 72bb65d commit 1367cee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/qase-tms/qasectl/internal"
"github.com/spf13/cobra"
"runtime/debug"
)

func VersionCmd() *cobra.Command {
Expand All @@ -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)
Expand Down

0 comments on commit 1367cee

Please sign in to comment.