Skip to content

Instantly share code, notes, and snippets.

@shamique
Last active August 18, 2018 15:00
Show Gist options
  • Save shamique/ebcf1fe6c8e37a8e784c086ee5db6905 to your computer and use it in GitHub Desktop.
Save shamique/ebcf1fe6c8e37a8e784c086ee5db6905 to your computer and use it in GitHub Desktop.
git hook - pre-commit
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
DIRTY_SYNTAX="console\|debugger\|<<<<<<<|=======|>>>>>>>"
git diff-index --name-status --cached $against -- | cut -c3- | while read FILE; do
if [[ -f $FILE ]]; then
if grep -w $DIRTY_SYNTAX $FILE;
then
echo $FILE ' contains debugger or console log!'
exit 1
fi
fi
done || exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment