Skip to content

Commit

Permalink
Add git pre commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dude333 committed Feb 25, 2020
1 parent 0effdd0 commit 1ee6a63
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# git config core.hooksPath .githooks

echo "Running pre-commit checks at `pwd`"

{
echo "go vet ./..."
go vet ./...
} || {
exitStatus=$?

if [ $exitStatus ]; then
printf "\ngo vet issues found in your code, please fix them and try again."
exit 1
fi
}

{
echo "golint ./..."
golint ./...
} || {
exitStatus=$?

if [ $exitStatus ]; then
printf "\nLint errors in your code, please fix them and try again."
exit 1
fi
}

{
echo "go test ./..."
go test ./...
} || {
exitStatus=$?

if [ $exitStatus ]; then
printf "\nTest errors in your code, please fix them and try again."
exit 1
fi
}

0 comments on commit 1ee6a63

Please sign in to comment.