Skip to content

Instantly share code, notes, and snippets.

@chronossc
Created January 6, 2015 12:34
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chronossc/0a46e2025154b9a45bce to your computer and use it in GitHub Desktop.
Save chronossc/0a46e2025154b9a45bce to your computer and use it in GitHub Desktop.
Basic pre-commit hook for avoid commit code with pdb/ipdb
#!/bin/bash
# based on http://www.snip2code.com/Snippet/165926/Check-for-ipdb-breakpoints-git-hook
pdb_check=$(git grep -E -n '[ ;]i?pdb')
if [ ${#pdb_check} -gt 0 ]
then
echo "COMMIT REJECTED: commit contains code with break points. Please remove before commiting."
echo $pdb_check
exit 1
else
echo "Code contains no break points"
fi
exit 0
@LucasMagnum
Copy link

HAHAHAHAHHAHA Super preguiça!

@medington
Copy link

Thanks for tip on git grep I adapted this solution to Python and added the --cached flag to only check staged files.

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