Skip to content

Commit

Permalink
Updates version string wity BuildTool/builder
Browse files Browse the repository at this point in the history
  • Loading branch information
TekWizely committed Jan 5, 2020
1 parent 4cd9fd0 commit 3792b87
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ import (

// Version stores the version tag - Should include leading 'v' - Update before tagging new versions.
//
var Version = "v0.6.5"
var Version = "v0.6.6"

// BuildDate is optional and can be set using '-ldflags "-X 'main.BuildDate=..."'.
//
var BuildDate string

// GitSummary is optional and can be set using '-ldflags "-X 'main.BuildDate=..."'.
// GitSummary is optional and can be set using '-ldflags "-X 'main.GitSummary=..."'.
// Generally meant to contain the value of:
// git describe --tags --dirty --always
//
var GitSummary string

// BuildTool is optional and can be set using '-ldflags "-X 'main.BuildTool=..."'.
var BuildTool string

// versionString generates a version string from available vars.
// Variable names are compatible with govvv
// Variable names are compatible with govvv where applicable
//
func versionString() string {
version := strings.Builder{}
Expand All @@ -26,27 +31,40 @@ func versionString() string {
//
version.WriteString(Version)

// BuildDate / GitSummary
// Extras
//
if len(BuildDate) > 0 || len(GitSummary) > 0 {
if len(BuildDate) > 0 || len(GitSummary) > 0 || len(BuildTool) > 0 {
if version.Len() > 0 {
version.WriteString(" ")
}
version.WriteString("(")
needsSpace := false
// Git Summary
//
if len(GitSummary) > 0 {
version.WriteString("build=")
version.WriteString(GitSummary)
needsSpace = true
}
// Build Date
//
if len(BuildDate) > 0 {
if len(GitSummary) > 0 {
if needsSpace {
version.WriteString(" ")
}
version.WriteString("date=")
version.WriteString(BuildDate)
needsSpace = true
}
// Build Tool
//
if len(BuildTool) > 0 {
if needsSpace {
version.WriteString(" ")
}
version.WriteString("builder=")
version.WriteString(BuildTool)
// needsSpace = true
}
version.WriteString(")")
}
Expand Down

0 comments on commit 3792b87

Please sign in to comment.