fix: empty version on source build (#1933)

This commit is contained in:
Luke Kingland 2023-08-16 05:54:40 +09:00 committed by GitHub
parent 1163a5e5ae
commit 49278270ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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()
}