Adds pre-commit hook, hook config script, and a README
The pre-commit hook will automatically gofmt code in place, warning you about any changes. It will also fail to commit if either golint or go vet fails.
This commit is contained in:
parent
a35273a0db
commit
1a6893dbb6
3 changed files with 53 additions and 0 deletions
18
project/hooks/configure-hooks.sh
Executable file
18
project/hooks/configure-hooks.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
REPO_ROOT=$(git rev-parse --show-toplevel)
|
||||
RESOLVE_REPO_ROOT_STATUS=$?
|
||||
if [ "$RESOLVE_REPO_ROOT_STATUS" -ne "0" ]; then
|
||||
echo -e "Unable to resolve repository root. Error:\n$REPO_ROOT" > /dev/stderr
|
||||
exit $RESOLVE_REPO_ROOT_STATUS
|
||||
fi
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Just in case the directory doesn't exist
|
||||
mkdir -p $REPO_ROOT/.git/hooks
|
||||
|
||||
ln -f -s $(pwd)/pre-commit $REPO_ROOT/.git/hooks/pre-commit
|
Loading…
Add table
Add a link
Reference in a new issue