Skip to content

Instantly share code, notes, and snippets.

@JustDevZero
Forked from chronossc/pre-commit
Last active February 14, 2022 15:19
Show Gist options
  • Save JustDevZero/3761912fd22489035dbce3aebf83c1e2 to your computer and use it in GitHub Desktop.
Save JustDevZero/3761912fd22489035dbce3aebf83c1e2 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 diff-index -U --color=always --cached -G '[ ;]i?pdb' HEAD)
if [ ${#pdb_check} -gt 0 ]
then
echo "COMMIT REJECTED: commit contains code with break points in python. Please remove before commiting."
echo $pdb_check
exit 1
else
echo "Code contains no break points in python"
fi
debugger_check=$(git diff-index -U --color=always --cached -G '[ ;]debugger' HEAD)
if [ ${#debugger_check} -gt 0 ]
then
echo "COMMIT REJECTED: commit contains code with break points in js. Please remove before commiting."
echo $debugger_check
exit 1
else
echo "Code contains no break points in js"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment