git commit hash generator

This commit is contained in:
Harshavardhana
2015-03-25 23:07:33 -07:00
parent 1c388fea0e
commit 4497de7f1d
4 changed files with 43 additions and 17 deletions
+1
View File
@@ -1,3 +1,4 @@
/build-constants.go
cover.out
mc
site/
+22 -12
View File
@@ -3,7 +3,7 @@ MINIOPATH=$(GOPATH)/src/github.com/minio-io/mc
all: getdeps install
checkdeps:
@echo "Checking deps.."
@echo "Checking deps:"
@(env bash $(PWD)/buildscripts/checkdeps.sh)
checkgopath:
@@ -11,34 +11,39 @@ checkgopath:
@if [ ! -d ${MINIOPATH} ]; then echo "Project not found in $GOPATH, please follow instructions provided at https://github.com/Minio-io/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi
getdeps: checkdeps checkgopath
@go get github.com/tools/godep && echo "Installed godep"
@go get github.com/golang/lint/golint && echo "Installed golint"
@go get golang.org/x/tools/cmd/vet && echo "Installed vet"
@go get github.com/fzipp/gocyclo && echo "Installed gocyclo"
@go get github.com/tools/godep && echo "Installed godep:"
@go get github.com/golang/lint/golint && echo "Installed golint:"
@go get golang.org/x/tools/cmd/vet && echo "Installed vet:"
@go get github.com/fzipp/gocyclo && echo "Installed gocyclo:"
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: getdeps verifiers
@echo "Building Libraries"
@echo "Building Libraries:"
@godep go generate ./...
@godep go build ./...
test-all: build-all
test-all: pre-build build-all
@echo "Running Test Suites:"
@godep go test -race ./...
@@ -55,5 +60,10 @@ docs-deploy:
@mkdocs gh-deploy --clean
install: test-all
@godep go install github.com/minio-io/mc && echo "Installed mc"
@godep go install github.com/minio-io/mc && echo "Installed mc:"
@mkdir -p $(HOME)/.minio/mc
clean:
@rm -fv cover.out
@rm -fv pkg/encoding/erasure/*.syso
@rm -fv build-constants.go
+19
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
+1 -5
View File
@@ -24,10 +24,6 @@ import (
"github.com/minio-io/cli"
)
// commitID is automatically set by git. Settings are controlled
// through .gitattributes
const commitID = "$Id$"
func init() {
// Check for the environment early on and gracefuly report.
_, err := user.Current()
@@ -54,7 +50,7 @@ func init() {
func main() {
app := cli.NewApp()
app.Usage = "Minio Client for S3 Compatible Object Storage"
app.Version = commitID
app.Version = gitCommitHash
app.Commands = options
app.Flags = flags
app.Author = "Minio.io"