git commit hash generator

This commit is contained in:
Anand Babu (AB) Periasamy 2015-03-25 22:51:19 -07:00
parent db2ac35da5
commit 3c4aa85c69
4 changed files with 34 additions and 14 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/build-constants.go
**/*.swp
cover.out
*~

View File

@ -19,22 +19,26 @@ getdeps: checkdeps checkgopath
verifiers: getdeps vet fmt lint cyclo
vet:
@echo "Running $@"
@echo "Running $@:"
@go vet ./...
fmt:
@echo "Running $@"
@echo "Running $@:"
@test -z "$$(gofmt -s -l . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)" || \
echo "+ please format Go code with 'gofmt -s'"
lint:
@echo "Running $@"
@echo "Running $@:"
@test -z "$$(golint ./... | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
cyclo:
@echo "Running $@"
@echo "Running $@:"
@test -z "$$(gocyclo -over 15 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
pre-build:
@echo "Running pre-build:"
@(env bash $(PWD)/buildscripts/git-commit-id.sh)
build-all: verifiers
@echo "Building Libraries"
@echo "Building Libraries:"
@godep go generate ./...
@godep go build ./...
@ -44,10 +48,10 @@ test-all: build-all
test: test-all
minio: build-all test-all
minio: pre-build build-all test-all
install: minio
@godep go install github.com/minio-io/minio && echo "Installed minio"
@godep go install github.com/minio-io/minio && echo "Installed minio:"
save: restore
@godep save ./...
@ -62,7 +66,7 @@ docs-deploy:
@mkdocs gh-deploy --clean
clean:
@echo "Cleaning up all the generated files"
@echo "Cleaning up all the generated files:"
@rm -fv pkg/utils/split/TESTPREFIX.*
@rm -fv cover.out
@rm -fv pkg/storage/erasure/*.syso

View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
CONST_FILE=build-constants.go
cat > $CONST_FILE <<EOF
/*
* ** DO NOT EDIT THIS FILE. THIS FILE IS AUTO GENERATED BY RUNNING MAKE **
*/
package main
const (
gitCommitHash = "__GIT_COMMIT_HASH__"
)
EOF
commit_id=$(git log --format="%H" -n 1)
sed -i "s/__GIT_COMMIT_HASH__/$commit_id/" $CONST_FILE

View File

@ -26,10 +26,6 @@ import (
"github.com/minio-io/minio/pkg/utils/log"
)
// commitID is automatically set by git. Settings are controlled
// through .gitattributes
const commitID = "$Id$"
var flags = []cli.Flag{
cli.StringFlag{
Name: "domain,d",
@ -123,13 +119,13 @@ func runCmd(c *cli.Context) {
func main() {
// set up iodine
iodine.SetGlobalState("minio.git", commitID)
iodine.SetGlobalState("minio.git", gitCommitHash)
iodine.SetGlobalState("minio.starttime", time.Now().Format(time.RFC3339))
// set up app
app := cli.NewApp()
app.Name = "minio"
app.Version = commitID
app.Version = gitCommitHash
app.Author = "Minio.io"
app.Usage = "Minimalist Object Storage"
app.EnableBashCompletion = true