Skip to content

Instantly share code, notes, and snippets.

@mkf-simpson
Created February 20, 2015 12:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mkf-simpson/02bde2f34791b32d2d7b to your computer and use it in GitHub Desktop.
Save mkf-simpson/02bde2f34791b32d2d7b to your computer and use it in GitHub Desktop.
pre-commit hook to prevent commit when there is a comment «UNCOMMITABLE»
#!/usr/bin/env bash
declare -i ERRORS=0
if git rev-parse --verify HEAD > /dev/null 2>&1
then
AGAINST=HEAD
else
AGAINST=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff-index --name-only $AGAINST --`;
do
if grep -q '\(#\|\/\/\|\;\|\-\-\)[[:blank:]]*UNCOMMITABLE' $FILE
then
echo -e "\033[41m$FILE\033[0m\033[31m contains uncommitable changes!\033[0m"
((ERRORS++))
fi
done
if [ $ERRORS -gt 0 ]
then
exit 1
fi
exit 0
@stanislaw
Copy link

👍

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