So, in .git/hooks/ directory of your repository create a file with name pre-commit and put
#!/bin/sh # comma-separated list of files and directories which are not for checking SKIP=migrations,bootstrap.py,dodo.py,manage.py pep8 -r --exclude=$SKIP .
UPDATE: The code above checks all the project Python files. To limit checking only for files going to be committed
#!/bin/sh
FILES=$(git diff --cached --name-status | awk '$1 $2 { print $2}' | grep -e \.py$)
if [ -n "$FILES" ]; then
pep8 -r $FILES
fi
The command shows all staged files, next only the filenames are left and filters Python files. If any they are to be checked with PEP8 utility.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.