Skip to content

Commit

Permalink
version of program from git tags auto.
Browse files Browse the repository at this point in the history
  • Loading branch information
soarpenguin committed Jul 19, 2016
1 parent 6b993fe commit a99d051
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ MKDIR = mkdir
INSTALL = install
BIN = $(BUILD_ROOT)
MAN = $(BIN)
VERSION = $(shell cat VERSION)
VERSION = $(shell git describe --tags)
RELEASE = 0
RPMSOURCEDIR = $(shell rpm --eval '%_sourcedir')
RPMSPECDIR = $(shell rpm --eval '%_specdir')
Expand All @@ -26,7 +26,7 @@ RPMBUILD = $(shell \
## Make bin for lvs-metrics.
bin: ${CURDIR_LINK}
#./control build
go build -i -ldflags "-X g.Commit=${COMMIT}" -o lvs-metrics .
go build -i -ldflags "-X github.com/mesos-utility/lvs-metrics/g.Version=${VERSION}" -o lvs-metrics .

## Get godep and restore dep.
godep:
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

7 changes: 3 additions & 4 deletions g/g.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"runtime"
)

const (
VERSION = "0.2.0"
Commit = ""
)
// version will be populated by the Makefile, read from
// VERSION file of the source code.
var Version = ""

func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
Expand Down
2 changes: 1 addition & 1 deletion g/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func CalculateMetricRatio(metrics ...string) string {
// display version info.
func HandleVersion(displayVersion bool) {
if displayVersion {
fmt.Println(VERSION)
fmt.Println(Version)
os.Exit(0)
}
}
Expand Down
2 changes: 1 addition & 1 deletion http/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func configCommonRoutes() {
})

http.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf("%s\n", g.VERSION)))
w.Write([]byte(fmt.Sprintf("%s\n", g.Version)))
})

http.HandleFunc("/workdir", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit a99d051

Please sign in to comment.