Browse Source

version: add GitCommitTime to Meta

Updates tailscale/corp#1297

Signed-off-by: Maisem Ali <[email protected]>
Maisem Ali 1 year ago
parent
commit
8feb4ff5d2
2 changed files with 6 additions and 0 deletions
  1. 4 0
      version/prop.go
  2. 2 0
      version/version.go

+ 4 - 0
version/prop.go

@@ -230,6 +230,9 @@ type Meta struct {
 	// daemon, if requested.
 	// daemon, if requested.
 	DaemonLong string `json:"daemonLong,omitempty"`
 	DaemonLong string `json:"daemonLong,omitempty"`
 
 
+	// GitCommitTime is the commit time of the git commit in GitCommit.
+	GitCommitTime string `json:"gitCommitTime,omitempty"`
+
 	// Cap is the current Tailscale capability version. It's a monotonically
 	// Cap is the current Tailscale capability version. It's a monotonically
 	// incrementing integer that's incremented whenever a new capability is
 	// incrementing integer that's incremented whenever a new capability is
 	// added.
 	// added.
@@ -245,6 +248,7 @@ func GetMeta() Meta {
 			MajorMinorPatch: majorMinorPatch(),
 			MajorMinorPatch: majorMinorPatch(),
 			Short:           Short(),
 			Short:           Short(),
 			Long:            Long(),
 			Long:            Long(),
+			GitCommitTime:   getEmbeddedInfo().commitTime,
 			GitCommit:       gitCommit(),
 			GitCommit:       gitCommit(),
 			GitDirty:        gitDirty(),
 			GitDirty:        gitDirty(),
 			ExtraGitCommit:  extraGitCommitStamp,
 			ExtraGitCommit:  extraGitCommitStamp,

+ 2 - 0
version/version.go

@@ -105,6 +105,7 @@ type embeddedInfo struct {
 	valid      bool
 	valid      bool
 	commit     string
 	commit     string
 	commitDate string
 	commitDate string
+	commitTime string
 	dirty      bool
 	dirty      bool
 }
 }
 
 
@@ -126,6 +127,7 @@ var getEmbeddedInfo = lazy.SyncFunc(func() embeddedInfo {
 		case "vcs.revision":
 		case "vcs.revision":
 			ret.commit = s.Value
 			ret.commit = s.Value
 		case "vcs.time":
 		case "vcs.time":
+			ret.commitTime = s.Value
 			if len(s.Value) >= len("yyyy-mm-dd") {
 			if len(s.Value) >= len("yyyy-mm-dd") {
 				ret.commitDate = s.Value[:len("yyyy-mm-dd")]
 				ret.commitDate = s.Value[:len("yyyy-mm-dd")]
 				ret.commitDate = strings.ReplaceAll(ret.commitDate, "-", "")
 				ret.commitDate = strings.ReplaceAll(ret.commitDate, "-", "")