Skip to content

Instantly share code, notes, and snippets.

@mamounothman
Forked from watsoncj/gist:1005449
Last active August 29, 2015 14:01
Show Gist options
  • Save mamounothman/a6afa2694bd457708f6a to your computer and use it in GitHub Desktop.
Save mamounothman/a6afa2694bd457708f6a to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This hook prevents you from committing any file containing the
# words "alert|die|print_r".
#
# The idea is that I can add a comment to prevent myself from
# committing a change related to debugging or hacking.
#
# To enable this hook, rename this file to ".git/hooks/pre-commit".
DIFF_FILES=`git diff-index HEAD --cached --name-only`
if [ $? -ne 0 ]
then
echo "Error getting list of changed files in pre-commit hook"
exit 4
fi
for FILE in ${DIFF_FILES}
do
egrep -rin -C2 "alert|die|print_r" "$FILE"
if [ $? -ne 0 ]
then
false
else
echo "---------------------------"
echo "Bad contents in file: $FILE"
exit 4
fi
done
exit 0
@Natshah
Copy link

Natshah commented May 12, 2014

Thanks :)

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