From 49278270ab5be84f1bbae7a26eef842f0a695299 Mon Sep 17 00:00:00 2001 From: Luke Kingland Date: Wed, 16 Aug 2023 05:54:40 +0900 Subject: [PATCH] fix: empty version on source build (#1933) --- cmd/root.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 2c143e67..234a1986 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -21,6 +21,9 @@ import ( "knative.dev/func/pkg/k8s" ) +// DefaultVersion when building source directly (bypassing the Makefile) +const DefaultVersion = "v0.0.0+source" + type RootCommandConfig struct { Name string // usually `func` or `kn func` Version @@ -336,6 +339,12 @@ type Version struct { // Return the stringification of the Version struct. func (v Version) String() string { + // Initialize the default value to the zero semver with a descriptive + // metadta tag indicating this must have been built from source if + // undefined: + if v.Vers == "" { + v.Vers = DefaultVersion + } if v.Verbose { return v.StringVerbose() }