Skip to content

Commit

Permalink
Merge pull request #62 from SimonBaeumer/add-githook
Browse files Browse the repository at this point in the history
Add githook
  • Loading branch information
SimonBaeumer authored Jul 9, 2019
2 parents b8ec2c1 + 31696ef commit aa03806
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

echo "Run gofmt..."
FMT_FILES=`gofmt -l . | grep -v "vendor/"`
if [[ $FMT_FILES != "" ]]; then
echo "Some files aren't formatted, please run 'go fmt ./...' to format your source code before committing"
echo "${FMT_FILES}"
exit 1
fi

echo "Run go vet..."
vetcount=`go vet ./... 2>&1 | wc -l`
if [ $vetcount -gt 0 ]; then
echo "Some files aren't passing vet heuristics, please run 'go vet ./...' to see the errors it flags and correct your source code before committing"
exit 1
fi
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ cmd = goss
TRAVIS_TAG ?= "0.0.0"
GO_FILES = $(shell find . \( -path ./vendor -o -name '_test.go' \) -prune -o -name '*.go' -print)

.PHONY: all build install test coverage deps release bench test-int lint gen integration
.PHONY: all build install test coverage deps release bench test-int lint gen integration init git-hooks

init: git-hooks

git-hooks:
$(info INFO: Starting build $@)
ln -sf ../../.githooks/pre-commit .git/hooks/pre-commit

all: test-all test-all-32

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ chmod +rx /usr/local/bin/dgoss
### Build it yourself

```bash
# Enable git-hooks for development environments
make init
# Build the source
make build
```

Expand Down

0 comments on commit aa03806

Please sign in to comment.