Skip to content

Instantly share code, notes, and snippets.

@rj76
Created November 29, 2018 12:32
Show Gist options
  • Save rj76/f93e83f2f3f23a7c401f3dcabc8fe511 to your computer and use it in GitHub Desktop.
Save rj76/f93e83f2f3f23a7c401f3dcabc8fe511 to your computer and use it in GitHub Desktop.
#!/bin/bash
FILES_PATTERN='\.py$'
FORBIDDEN='import ipdb'
MSG="COMMIT REJECTED. Found \"${FORBIDDEN}\" references. Please remove them before commiting."
# check for debug stuff
git diff --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n "$FORBIDDEN" && echo $MSG && exit 1
# run tests
`which python` `which pytest` -x
RESULT=$?
[ $RESULT -ne 0 ] && exit 1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment