Skip to content

Instantly share code, notes, and snippets.

@scottsb
Forked from timsweb/pre-commit
Last active July 15, 2017 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottsb/f144abaae78912f9d9733d419759524d to your computer and use it in GitHub Desktop.
Save scottsb/f144abaae78912f9d9733d419759524d to your computer and use it in GitHub Desktop.
Git hook to prevent committing xdebug_break() functions. Save as .git/hooks/pre-commit then chmod +x it. Submodules also have their own hooks folder: ".git/modules/submodule/path/here/hooks".
#!/bin/sh
for FILE in `git diff --cached --name-only` ; do
# Check if the file contains 'debugger'
grep -qE '^[ \t]*xdebug_break()' $FILE
if [[ $? -eq 0 ]]
then
echo $FILE ' contains xdebug_break()! To commit retry with --no-verify'
exit 1
fi
done
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment