diff --git a/cmd/program.go b/cmd/program.go index 5a251df9bb98f7eb2ca1587c14f4b2480718a943_Y21kL3Byb2dyYW0uZ28=..06a165ffa439e8d3541b260f9dab4f38077ae6d0_Y21kL3Byb2dyYW0uZ28= 100644 --- a/cmd/program.go +++ b/cmd/program.go @@ -143,6 +143,8 @@ type Version struct { Version string Hash string + Branch string + HgTopic string Build string } diff --git a/cmd/version.go b/cmd/version.go index 5a251df9bb98f7eb2ca1587c14f4b2480718a943_Y21kL3ZlcnNpb24uZ28=..06a165ffa439e8d3541b260f9dab4f38077ae6d0_Y21kL3ZlcnNpb24uZ28= 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -25,7 +25,6 @@ } func (cmd *VersionCmd) Execute([]string) error { - versionLine := cmd.program.Version.Version if cmd.Verbose { if cmd.program.Version.Hash != "" { @@ -29,6 +28,12 @@ versionLine := cmd.program.Version.Version if cmd.Verbose { if cmd.program.Version.Hash != "" { - versionLine += "\nHash:" + cmd.program.Version.Hash + versionLine += "\nHash: " + cmd.program.Version.Hash + } + if cmd.program.Version.HgTopic != "" { + versionLine += "\nTopic: " + cmd.program.Version.HgTopic + } + if cmd.program.Version.Branch != "" { + versionLine += "\nBranch: " + cmd.program.Version.Branch } if cmd.program.Version.Build != "" { @@ -33,6 +38,6 @@ } if cmd.program.Version.Build != "" { - versionLine += "\nBuild:" + cmd.program.Version.Build + versionLine += "\nBuild: " + cmd.program.Version.Build } } if _, err := fmt.Println(versionLine); err != nil { diff --git a/tools/build_version_file/main.go b/tools/build_version_file/main.go index 5a251df9bb98f7eb2ca1587c14f4b2480718a943_dG9vbHMvYnVpbGRfdmVyc2lvbl9maWxlL21haW4uZ28=..06a165ffa439e8d3541b260f9dab4f38077ae6d0_dG9vbHMvYnVpbGRfdmVyc2lvbl9maWxlL21haW4uZ28= 100644 --- a/tools/build_version_file/main.go +++ b/tools/build_version_file/main.go @@ -42,6 +42,7 @@ if len(candidates) == 0 { return "" } + return candidates[0] } @@ -49,6 +50,8 @@ var Version = "{{ .version }}" var HgSha = "{{ .sha }}" +var HgTopic = "{{ .topic }}" +var HgBranch = "{{ .branch }}" var Build = "{{ .build }}" `)) @@ -59,6 +62,12 @@ modified := strings.HasSuffix(sha, "+") jobID := os.Getenv("CI_JOB_ID") + topic := syscmd("hg", "topic", "--current") + if topic == "no active topic" { + topic = "" + } + branch := syscmd("hg", "id", "--branch") + var version string switch { @@ -77,6 +86,8 @@ "sha": sha, "version": version, "build": jobID, + "topic": topic, + "branch": branch, } out, err := os.Create("version.go")