From 17e4cf0d304fb7f7eb2b3f5b52573b8fffce314b Mon Sep 17 00:00:00 2001 From: Sharif Nassar Date: Wed, 2 Sep 2015 14:41:57 -0700 Subject: [PATCH] Fix version info string. Broken by the following commit e38bb7c Use Makefile.COMMON and add generated files.go --- Makefile | 12 ++++++++++++ build_info.go | 14 ++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1e1245fd..97e7ba93 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,18 @@ TARGET := alertmanager include Makefile.COMMON +REV := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown') +BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2> /dev/null || echo 'unknown') +HOSTNAME := $(shell hostname -f) +BUILD_DATE := $(shell date +%Y%m%d-%H:%M:%S) +GOFLAGS := -ldflags \ + "-X=main.buildVersion $(VERSION)\ + -X=main.buildRevision $(REV)\ + -X=main.buildBranch $(BRANCH)\ + -X=main.buildUser $(USER)@$(HOSTNAME)\ + -X=main.buildDate $(BUILD_DATE)\ + -X=main.goVersion $(GO_VERSION)" + web: web/blob/files.go web/blob/files.go: $(shell find web/templates/ web/static/ -type f) diff --git a/build_info.go b/build_info.go index 6ed4aecb..c6885dee 100644 --- a/build_info.go +++ b/build_info.go @@ -19,17 +19,19 @@ import ( // Build information. Populated by Makefile. var ( - buildVersion string - buildBranch string - buildUser string - buildDate string - goVersion string + buildVersion string + buildRevision string + buildBranch string + buildUser string + buildDate string + goVersion string ) // BuildInfo encapsulates compile-time metadata about Prometheus made available // via go tool ld such that this can be reported on-demand. var BuildInfo = map[string]string{ "version": buildVersion, + "revision": buildRevision, "branch": buildBranch, "user": buildUser, "date": buildDate, @@ -37,7 +39,7 @@ var BuildInfo = map[string]string{ } var versionInfoTmpl = template.Must(template.New("version").Parse( - `alertmanager, version {{.version}} ({{.branch}}) + `alertmanager, version {{.version}} ({{.branch}}@{{.revision}}) build user: {{.user}} build date: {{.date}} go version: {{.go_version}}