From ace156f52c315981b1bd42c948701c26dd0c3a37 Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Tue, 8 Apr 2014 19:52:43 +0000 Subject: add bin to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 215e0cc..b2bb382 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.prof *.test +/bin/ -- cgit v1.2.3 From 38b69be6804306a919363d4d12bcfebb62ec97ca Mon Sep 17 00:00:00 2001 From: Steven Normore Date: Wed, 9 Apr 2014 11:49:19 +0000 Subject: add ldflags on build with main.commit and main.branch to Makefile --- Makefile | 5 ++++- cmd/bolt/main.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ec11e77..8fe231b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,9 @@ TEST=. BENCH=. COVERPROFILE=/tmp/c.out +BRANCH=`git rev-parse --abbrev-ref HEAD` +COMMIT=`git rev-parse --short HEAD` +GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" bench: benchpreq go test -v -test.bench=$(BENCH) @@ -31,7 +34,7 @@ get: build: get @mkdir -p bin - @go build -a -o bin/bolt-`git rev-parse --short HEAD` ./cmd/bolt + @go build -ldflags=$(GOLDFLAGS) -a -o bin/bolt-`git rev-parse --short HEAD` ./cmd/bolt test: fmt errcheck @go get github.com/stretchr/testify/assert diff --git a/cmd/bolt/main.go b/cmd/bolt/main.go index bc5fadb..ff3c1bf 100644 --- a/cmd/bolt/main.go +++ b/cmd/bolt/main.go @@ -9,6 +9,8 @@ import ( "github.com/codegangsta/cli" ) +var branch, commit string + func main() { log.SetFlags(0) NewApp().Run(os.Args) @@ -19,7 +21,7 @@ func NewApp() *cli.App { app := cli.NewApp() app.Name = "bolt" app.Usage = "BoltDB toolkit" - app.Version = "0.1.0" + app.Version = fmt.Sprintf("0.1.0 (%s %s)", branch, commit) app.Commands = []cli.Command{ { Name: "get", -- cgit v1.2.3