build: Add git sha to version output

This commit is contained in:
Derek Parker 2015-12-13 13:51:11 -08:00 committed by aarzilli
parent 4a652b8f91
commit 0abc772023
2 changed files with 10 additions and 2 deletions

@ -2,6 +2,13 @@
UNAME=$(shell uname)
PREFIX=github.com/derekparker/delve
GOVERSION=$(shell go version)
BUILD_SHA=$(shell git rev-parse HEAD)
ifeq "$(UNAME)" "Darwin"
BUILD_FLAGS=-ldflags="-s -X main.Build=$(BUILD_SHA)"
else
BUILD_FLAGS=-ldflags="-X main.Build=$(BUILD_SHA)"
endif
# Workaround for GO15VENDOREXPERIMENT bug (https://github.com/golang/go/issues/11659)
ALL_PACKAGES=$(shell go list ./... | grep -v /vendor/)
@ -13,7 +20,6 @@ ALL_PACKAGES=$(shell go list ./... | grep -v /vendor/)
# unable to execute.
# See https://github.com/golang/go/issues/11887#issuecomment-126117692.
ifeq "$(UNAME)" "Darwin"
BUILD_FLAGS=-ldflags="-s"
TEST_FLAGS=-exec=$(shell pwd)/scripts/testsign
DARWIN="true"
endif

@ -24,6 +24,8 @@ import (
const version string = "0.10.0-alpha"
var Build string
var (
Log bool
Headless bool
@ -59,7 +61,7 @@ The goal of this tool is to provide a simple yet powerful interface for debuggin
Use: "version",
Short: "Prints version.",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Delve version: " + version)
fmt.Printf("Delve Debugger\nVersion: %s\nBuild: %s\n", version, Build)
},
}
rootCommand.AddCommand(versionCommand)