Don't embed git commit sha in version command output

This commit is contained in:
Marcin Kulik
2015-07-02 21:41:27 +02:00
parent 971e49ea21
commit ec6bce8f07
2 changed files with 4 additions and 13 deletions

View File

@@ -1,6 +1,5 @@
NAME=asciinema
VERSION=$(shell grep 'const Version' main.go | awk -F '"' '{print $$2}')
COMMIT=$(shell git rev-parse --short HEAD)
DIRS=bin
INSTALL_DIRS=`find $(DIRS) -type d 2>/dev/null`
@@ -15,7 +14,7 @@ DOC_DIR=$(PREFIX)/share/doc/$(NAME)
all: build
build: test
go build -o bin/asciinema -ldflags "-X main.GitCommit $(COMMIT)"
go build -o bin/asciinema
test:
go test ./...
@@ -29,7 +28,7 @@ fmtdiff:
travis: build fmtdiff
gox:
gox -os="darwin freebsd linux" -arch="386 amd64" -output="bin/asciinema_{{.OS}}_{{.Arch}}" -ldflags "-X main.GitCommit $(COMMIT)"
gox -os="darwin freebsd linux" -arch="386 amd64" -output="bin/asciinema_{{.OS}}_{{.Arch}}"
tag:
git tag | grep "v$(VERSION)" && echo "Tag v$(VERSION) exists" && exit 1 || true
@@ -65,6 +64,6 @@ RELEASE=asciinema-$(VERSION)-$(GOOS)-$(GOARCH)
os-arch-tgz:
mkdir -p dist/$(VERSION)/$(RELEASE)
go build -o dist/$(VERSION)/$(RELEASE)/asciinema -ldflags "-X main.GitCommit $(COMMIT)"
go build -o dist/$(VERSION)/$(RELEASE)/asciinema
cp README.md CHANGELOG.md LICENSE dist/$(VERSION)/$(RELEASE)
cd dist/$(VERSION) && tar czf $(RELEASE).tar.gz $(RELEASE)

10
main.go
View File

@@ -14,8 +14,6 @@ import (
const Version = "1.1.1"
var GitCommit string // initialized during build
var usage = `Record and share your terminal sessions, the right way.
Usage:
@@ -79,13 +77,7 @@ func uintArg(args map[string]interface{}, name string, defaultValue uint) uint {
}
func formatVersion() string {
var commitInfo string
if GitCommit != "" {
commitInfo = "-" + GitCommit
}
return fmt.Sprintf("asciinema %v%v\n", Version, commitInfo)
return fmt.Sprintf("asciinema %v", Version)
}
func environment() map[string]string {