Skip to content

Instantly share code, notes, and snippets.

@jlnwlf
Created March 20, 2014 09:04
Show Gist options
  • Save jlnwlf/9659899 to your computer and use it in GitHub Desktop.
Save jlnwlf/9659899 to your computer and use it in GitHub Desktop.
git pre-commit hook for Python Unittest + autopep8 check
#!/bin/bash
autopep=$(autopep8 -dr .)
if [[ -z $autopep ]]
then
echo "> PEP8 passed !"
else
echo "> PEP8 DID NOT pass !"
echo "$autopep" | colordiff
exit 1
fi
if [[ `python -m unittest discover .` ]]
then
echo "> Tests DID NOT pass !"
exit 1
else
echo "> Tests passed !"
fi
echo "Ready to commit !"
exit 0
@ramitmittal
Copy link

@vitalybe
Thanks for the correction. This works !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment