Skip to content

Instantly share code, notes, and snippets.

@yonglam
Last active March 1, 2016 11:18
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 yonglam/2478fd21fccf7764f1d7 to your computer and use it in GitHub Desktop.
Save yonglam/2478fd21fccf7764f1d7 to your computer and use it in GitHub Desktop.
Check some restrictive condition befor commit to svn server
#!/bin/sh
# Check test code
v=$(svn diff | grep -i -e '^\+.*paul' -e '^\+.*//.*@test' -e '^\+.*/\*.*@test' -e '^\+.*DevelopmentTeam\s*=\s*')
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=$(svn 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"
svn ci "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment