Created
February 4, 2016 09:43
-
-
Save yonglam/6760b264b643dc824249 to your computer and use it in GitHub Desktop.
Check some restrictive condition before ci to local git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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