add a pre-commit hook

pull/681/merge
John Shahid 2014-06-23 12:53:50 -04:00
parent 17832294d2
commit 9dac392f26
2 changed files with 11 additions and 2 deletions

8
.hooks/pre-commit Executable file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
count=`git ls-files | grep '.go$' | xargs gofmt -l | wc -l`
if [ $count -gt 0 ]; then
echo "Some files aren't formatted, please run 'make format' to format your source code before committing"
exit 1
fi
exit 0

View File

@ -376,8 +376,9 @@ packages:
package: | packages build package_version_string $(files)
mv -f scripts/post_install.sh.bak scripts/post_install.sh
check_format:
git ls-files | grep '.go$$' | xargs gofmt -l
check:
./.hooks/pre-commit
format:
git ls-files | grep '.go$$' | xargs gofmt -w -s