From 288899e58fdfa9ed3e4969934a8b414c7d3e1d2a Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Fri, 23 Feb 2024 15:48:01 +0100 Subject: [PATCH] cmd/skipper: do not show empty commit Binary installed via `go install github.com/zalando/skipper/cmd/skipper@latest` does not contain `vcs.revision`, see https://github.com/golang/go/issues/65904 Followup on #2954 Signed-off-by: Alexander Yastrebov --- cmd/skipper/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/skipper/main.go b/cmd/skipper/main.go index 48bc89a747..5ed5106f9b 100644 --- a/cmd/skipper/main.go +++ b/cmd/skipper/main.go @@ -38,6 +38,7 @@ func init() { for _, setting := range info.Settings { if setting.Key == "vcs.revision" { commit = setting.Value[:min(8, len(setting.Value))] + break } } } @@ -51,11 +52,11 @@ func main() { } if cfg.PrintVersion { - fmt.Printf( - "Skipper version %s (commit: %s, runtime: %s)\n", - version, commit, runtime.Version(), - ) - + fmt.Printf("Skipper version %s (", version) + if commit != "" { + fmt.Printf("commit: %s, ", commit) + } + fmt.Printf("runtime: %s)\n", runtime.Version()) return }