tools: add a pre-commit check for the python code
[gtk-doc.git] / tools / git-pre-commit
blob2b1e189ee9472da3a49fbd5bed9ab4168fe03fe1
1 #!/bin/sh
2 # git hook to ensure code style
3 # cp tools/git-pre-commit .git/hooks/pre-commit
5 which >/dev/null pep8 || (echo "please install pep8"; exit )
6 files=$(git diff --name-only --staged --diff-filter=ACMRTUXB | egrep "*.py$")
8 if test -n "$files"; then
9 pep8 --max-line-length=120 $files
10 res=$?
11 if [ $res -ne 0 ]; then
12 echo
13 autopep8 --max-line-length=120 --diff $files
14 echo
15 echo "To fix run: autopep8 --max-line-length=120 -i $files"
17 exit $res