Adding pre-commit pep8/pylint hook

This commit is contained in:
Alec Leamas 2013-03-19 06:11:29 +01:00
parent 5c03d4b622
commit f5df68340b
2 changed files with 19 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.log
*.pyc
*.patch
__init__.py

18
git-hooks/pre-commit Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
FILES=$(git diff --cached --name-status | \
grep -v ^D | awk '$1 $2 { print $2}' | egrep -e '.py$|.tmpl$')
if [ -n "$FILES" ]; then
pep8 --config pep8.conf $FILES
if [ $? -ne 0 ]; then
echo "pep8 failed ('git commit --no-verify' to override)"
exit 1
fi
export PYTHONPATH=src/
pylint --rcfile=pylint.conf -f text $FILES
if [ $? -ne 0 ]; then
echo "pylint failed ('git commit --no-verify' to override)'"
exit 1
fi
fi