Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Check for Drupal Debugging Statements Before Committing Code
# Check for debugging statements before commiting your code.
# Place this file in the .git/hooks directory of your project.
# List of function names to search for in regex format
# If any functions are found as executable, prevent the commit.
echo "Running the debugger check..."
RES=`egrep -nr --exclude-dir=".git" --exclude-dir="*devel*" "^(\s*)?[^/{2}]($FUNCTIONS)\(.*\)" .`
if [[ -n "$RES" ]]; then
echo "\n$RES"
echo "\nDebugging functions were found in your code!"
if [[ $DIEONFAIL == true ]]; then
echo "Changes were not committed."
exit 1;
echo "You may want to clean these up before you push those changes.\nChanges were committed anyway.\n"
exit 0;
echo "\n No debugging functions were found. Nice job, Ace!\n";
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.