2014-11-24 10:45:48 -05:00
|
|
|
|
|
|
|
# Adds build information from git repo
|
|
|
|
#
|
|
|
|
# as suggested by tatsushid in
|
|
|
|
# https://github.com/spf13/hugo/issues/540
|
|
|
|
|
|
|
|
COMMIT_HASH=`git rev-parse --short HEAD 2>/dev/null`
|
|
|
|
BUILD_DATE=`date +%FT%T%z`
|
2015-08-20 16:48:42 -04:00
|
|
|
LDFLAGS=-ldflags "-X github.com/spf13/hugo/hugolib.CommitHash=${COMMIT_HASH} -X github.com/spf13/hugo/hugolib.BuildDate=${BUILD_DATE}"
|
2014-11-24 10:45:48 -05:00
|
|
|
|
|
|
|
all: gitinfo
|
|
|
|
|
2014-12-08 21:54:49 -05:00
|
|
|
install: install-gitinfo
|
|
|
|
|
2014-11-24 10:45:48 -05:00
|
|
|
help:
|
|
|
|
echo ${COMMIT_HASH}
|
|
|
|
echo ${BUILD_DATE}
|
|
|
|
|
|
|
|
gitinfo:
|
|
|
|
go build ${LDFLAGS} -o hugo main.go
|
|
|
|
|
2014-12-08 21:54:49 -05:00
|
|
|
install-gitinfo:
|
|
|
|
go install ${LDFLAGS} ./...
|
|
|
|
|
2014-11-24 10:45:48 -05:00
|
|
|
no-git-info:
|
|
|
|
go build -o hugo main.go
|
|
|
|
|
2016-01-04 02:27:21 -05:00
|
|
|
docker:
|
|
|
|
docker build -t hugo .
|
|
|
|
docker rm -f hugo-build || true
|
|
|
|
docker run --name hugo-build hugo ls /go/bin
|
|
|
|
docker cp hugo-build:/go/bin/hugo .
|
|
|
|
docker rm hugo-build
|
2016-03-21 10:49:18 -04:00
|
|
|
|
2016-09-18 18:10:10 -04:00
|
|
|
govendor:
|
|
|
|
go get -u github.com/kardianos/govendor
|
|
|
|
go install github.com/kardianos/govendor
|
|
|
|
govendor get github.com/spf13/hugo
|
2016-03-21 10:49:18 -04:00
|
|
|
|
2016-09-18 18:10:10 -04:00
|
|
|
check: fmt vet test test-race
|
2016-03-21 10:49:18 -04:00
|
|
|
|
|
|
|
cyclo:
|
2016-09-18 18:10:10 -04:00
|
|
|
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
|
2016-03-21 10:49:18 -04:00
|
|
|
if [ "`gocyclo -over 20 $$d | tee /dev/stderr`" ]; then \
|
|
|
|
echo "^ cyclomatic complexity exceeds 20, refactor the code!" && echo && exit 1; \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
fmt:
|
2016-09-18 18:10:10 -04:00
|
|
|
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
|
2016-03-21 10:49:18 -04:00
|
|
|
if [ "`gofmt -l $$d/*.go | tee /dev/stderr`" ]; then \
|
|
|
|
echo "^ improperly formatted go files" && echo && exit 1; \
|
|
|
|
fi \
|
|
|
|
done
|
|
|
|
|
|
|
|
lint:
|
2016-09-18 18:10:10 -04:00
|
|
|
@for d in `govendor list -no-status +local | sed 's/github.com.spf13.hugo/./'` ; do \
|
|
|
|
if [ "`golint $$d | tee /dev/stderr`" ]; then \
|
|
|
|
echo "^ golint errors!" && echo && exit 1; \
|
|
|
|
fi \
|
|
|
|
done
|
2016-03-21 10:49:18 -04:00
|
|
|
|
2016-08-16 10:09:19 -04:00
|
|
|
get:
|
|
|
|
go get -v -t ./...
|
|
|
|
|
2016-03-21 10:49:18 -04:00
|
|
|
test:
|
2016-09-18 18:10:10 -04:00
|
|
|
govendor test +local
|
2016-03-21 10:49:18 -04:00
|
|
|
|
2016-04-07 07:36:48 -04:00
|
|
|
test-race:
|
2016-09-18 18:10:10 -04:00
|
|
|
govendor test -race +local
|
2016-04-07 07:36:48 -04:00
|
|
|
|
2016-03-21 10:49:18 -04:00
|
|
|
vet:
|
2016-09-18 18:10:10 -04:00
|
|
|
@if [ "`govendor vet +local | tee /dev/stderr`" ]; then \
|
2016-03-21 10:49:18 -04:00
|
|
|
echo "^ go vet errors!" && echo && exit 1; \
|
|
|
|
fi
|
|
|
|
|