2 # git hook to ensure code style
3 # cp tools/git-pre-commit .git/hooks/pre-commit
6 # pylint -r n -f parseable $files
8 which >/dev
/null pep8 ||
(echo "please install pep8"; exit )
9 which >/dev
/null autopep8 ||
(echo "please install autopep8"; exit )
10 which >/dev
/null pyflakes ||
(echo "please install pyflakes"; exit )
12 files
=$
(git
diff --name-only --staged --diff-filter=ACMRTUXB |
egrep "*.py$")
14 if test -n "$files"; then
15 pep8
--max-line-length=120 $files
17 if [ $res -ne 0 ]; then
19 autopep8
--max-line-length=120 --diff $files
21 echo "To fix run: autopep8 --max-line-length=120 -i $files"