Change version string format and add VendorInfo to help with issue triaging
authorAnthony Fok <foka@debian.org>
Tue, 16 Feb 2021 15:08:24 +0000 (08:08 -0700)
committerGitHub <noreply@github.com>
Tue, 16 Feb 2021 15:08:24 +0000 (16:08 +0100)
* Change version string format as proposed by @moorereason

 1. shorten program name
 2. make version string semver compliant with +extended.
    The slash is not allowed in semver.
 3. Use key=value pairs for BuildDate etc.

* Add optional vendorInfo to version string

to help with issue triaging, e.g. VendorInfo=debian:0.80.0-7

common/hugo/hugo.go
common/hugo/version.go

index 702da0dede7b04aca11b6a12a15b3b2573777388..67e8e40a6d0f29617f4a6965ab5dd8fc52ad170d 100644 (file)
@@ -40,6 +40,9 @@ var (
 
        // buildDate contains the date of the current build.
        buildDate string
+
+       // vendorInfo contains vendor notes about the current build.
+       vendorInfo string
 )
 
 // Info contains information about the current Hugo environment
index b87dab547977870aec2de8bb1567eb8dca4641f2..531f4483dfa82098658e97fa7636ddc211ad8c1d 100644 (file)
@@ -127,14 +127,15 @@ func (v Version) NextPatchLevel(level int) Version {
 // BuildVersionString creates a version string. This is what you see when
 // running "hugo version".
 func BuildVersionString() string {
-       program := "Hugo Static Site Generator"
+       // program := "Hugo Static Site Generator"
+       program := "hugo"
 
        version := "v" + CurrentVersion.String()
        if commitHash != "" {
                version += "-" + strings.ToUpper(commitHash)
        }
        if IsExtended {
-               version += "/extended"
+               version += "+extended"
        }
 
        osArch := runtime.GOOS + "/" + runtime.GOARCH
@@ -144,7 +145,14 @@ func BuildVersionString() string {
                date = "unknown"
        }
 
-       return fmt.Sprintf("%s %s %s BuildDate: %s", program, version, osArch, date)
+       versionString := fmt.Sprintf("%s %s %s BuildDate=%s",
+               program, version, osArch, date)
+
+       if vendorInfo != "" {
+               versionString += " VendorInfo=" + vendorInfo
+       }
+
+       return versionString
 }
 
 func version(version float32, patchVersion int, suffix string) string {