sascha-andres/git-commit

View on GitHub
Makefile

Summary

Maintainability
Test Coverage
.PHONY: test

test: ## Run all the tests
    rm -f coverage.tmp && rm -f coverage.txt
    echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test -race -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp

cover: test ## Run all the tests and opens the coverage report
    go tool cover -html=coverage.txt

fmt: ## gofmt and goimports all go files
    find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done

fmt-run: ## run gofmt all go files without changing
    find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -l -s "$$file"; done

lint:  fmt ## Run all the linters
    gometalinter --vendor --disable-all \
        --enable=deadcode \
        --enable=gocyclo \
        --enable=ineffassign \
        --enable=gosimple \
        --enable=staticcheck \
        --enable=gofmt \
        --enable=golint \
        --enable=goimports \
        --enable=dupl \
        --enable=misspell \
        --enable=errcheck \
        --enable=vet \
        --enable=vetshadow \
        --enable=varcheck \
        --enable=structcheck \
        --enable=interfacer \
        --enable=goconst \
        --deadline=10m \
        ./...

test-file:
    make build; mv .build/git-hook-commit ~/go/bin; git-hook-commit test/commit-message

snapshot: ## Create snapshot build
    goreleaser --skip-publish --rm-dist --snapshot

release: ## Create release build
    goreleaser --rm-dist

build: ## build binary to .build folder
    -rm -f .build/git-hook-commit
    go build -o ".build/git-hook-commit" cmd/main.go

# Self-Documented Makefile see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
    @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help