If you're using this, try
https://github.com/alexcouper/captainhook
At the time of writing it provides git hook checks for pdb, pep8 and python3 syntax straight out of the box.
If you're using this, try
https://github.com/alexcouper/captainhook
At the time of writing it provides git hook checks for pdb, pep8 and python3 syntax straight out of the box.
| # This hook was inspired by the work done on these two blogs: | |
| # - http://blog.keul.it/2013/11/no-more-pdbsettrace-committed-git-pre.html | |
| # - http://codeinthehole.com/writing/tips-for-using-a-git-pre-commit-hook/ | |
| # Ensure that code that isn't part of the prospective commit isn't tested | |
| # within the pre-commit script using git stash. | |
| git stash -q --keep-index | |
| # Test prospective commit | |
| FILES_PATTERN='\.py(\..+)?$' | |
| FORBIDDEN_PATTERN='^[^#]*pdb.set_trace()' | |
| FORBIDDEN_FILES=`git diff --cached --name-only | \ | |
| grep -E $FILES_PATTERN | \ | |
| GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n \ | |
| -e $FORBIDDEN_PATTERN` | |
| [ -n "$FORBIDDEN_FILES" ] && echo "COMMIT REJECTED \n$FORBIDDEN_FILES" | |
| RETVAL=$? | |
| git stash pop -q | |
| [ $RETVAL -eq 1 ] && exit 0 |
I would have thought you would have used the grep command --colour instead of --color 🇬🇧 😏
Nice!