Skip to content

Instantly share code, notes, and snippets.

@stanislaw
Forked from mkf-simpson/uncommitable-hook.sh
Last active August 29, 2015 14:15
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 stanislaw/7b1e77c6d60acc365baa to your computer and use it in GitHub Desktop.
Save stanislaw/7b1e77c6d60acc365baa to your computer and use it in GitHub Desktop.
#!/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
Author

👍

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