Skip to content

Instantly share code, notes, and snippets.

@yonglam
Created February 4, 2016 09:43
Show Gist options
  • Save yonglam/6760b264b643dc824249 to your computer and use it in GitHub Desktop.
Save yonglam/6760b264b643dc824249 to your computer and use it in GitHub Desktop.
Check some restrictive condition before ci to local git
#!/bin/sh
# Check test code
v=$(git diff | grep -i -e '^\+.*paul' -e '^\+.*//.*@test' -e '^\+.*/\*.*@test')
if [ "x$v" != "x" ]
then
echo "\033[31m Commit Failed! *** Reason: Test codes are added! *** \033[0m"
echo "$v"
exit
fi
# Check .m file
v=$(git diff | grep -i -e '^\+.*/\*.*\.m\b')
if [ "x$v" != "x" ]
then
echo "\033[31m Commit Failed! *** Reason: .m files are added! *** \033[0m"
echo "$v"
exit
fi
# Commit
echo "\033[36m Pre-commit checked OK. Start commit... \033[0m"
git ci "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment