anvil/tools/pre-commit
Alessio Ababilov 5ecd401a0a Configure pylint and update the code
This will allow us to run automatic checks for future commits.

Change-Id: Idbf08a44df0a940de51fb418d99f90da19fa6dc3
2013-05-31 18:22:47 -07:00

28 lines
655 B
Bash
Executable File

#!/bin/bash
# install me this way:
# cp pre-commit "$(git rev-parse --git-dir)/hooks/"
git stash -q --keep-index
trap 'git stash pop -q' EXIT
STATUS=0
FILES="$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py$')"
if [ -n "$FILES" ]; then
pylint $FILES || STATUS=1
if grep -nEH --color '(import pdb|pdb.set_trace)' $FILES; then
echo "Please remove pdb"
STATUS=1
fi
fi
FILES="$(git diff --cached --name-only --diff-filter=AM | grep -E '\.(py|html|js)$')"
if [ -n "$FILES" ]; then
if grep -nEH --color '\s+$' $FILES; then
echo "Please remove trailing spaces"
STATUS=1
fi
fi
exit $STATUS