From b1a73142b50d5c989af0eced70feb8b6f5b860c0 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Mon, 9 Apr 2018 10:08:54 +1000 Subject: [PATCH] Expose current git commit --- .goreleaser.yml | 2 ++ irc/constants.go | 3 +++ oragono.go | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/.goreleaser.yml b/.goreleaser.yml index 1a256765..9054b6a0 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -45,3 +45,5 @@ archive: - languages/*.md checksum: name_template: "{{ .ProjectName }}-{{ .Version }}-checksums.txt" +git: + short_hash: true diff --git a/irc/constants.go b/irc/constants.go index ba2b5661..7338508a 100644 --- a/irc/constants.go +++ b/irc/constants.go @@ -13,6 +13,9 @@ const ( ) var ( + // Commit is the current git commit. + Commit = "" + // Ver is the full version of Oragono, used in responses to clients. Ver = fmt.Sprintf("oragono-%s", SemVer) diff --git a/oragono.go b/oragono.go index 14df0b00..0ccc3ed2 100644 --- a/oragono.go +++ b/oragono.go @@ -22,6 +22,8 @@ import ( "golang.org/x/crypto/ssh/terminal" ) +var commit = "" + func main() { version := irc.SemVer usage := `oragono. @@ -98,6 +100,17 @@ Options: rand.Seed(time.Now().UTC().UnixNano()) if !arguments["--quiet"].(bool) { logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer)) + if commit == "" { + logman.Debug("startup", fmt.Sprintf("Could not get current commit")) + } else { + logman.Info("startup", fmt.Sprintf("Running commit %s", commit)) + } + } + + // set current git commit + irc.Commit = commit + if commit != "" { + irc.Ver = fmt.Sprintf("%s-%s", irc.Ver, commit) } // profiling