Created
June 2, 2014 09:02
-
-
Save dominikkukacka/dbbe95929958ecc8f5de to your computer and use it in GitHub Desktop.
Git Hooks
This file contains hidden or 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/bash | |
# prevents direct commits to develop and master branch | |
forbidden_branches=('develop' 'master') | |
function current_branch() { | |
echo `git rev-parse --abbrev-ref=strict HEAD | sed -n 1,1p` | |
} | |
branch=$(current_branch) | |
match=$(echo "${forbidden_branches[@]:0}" | grep -o $branch) | |
if [[ ! -z $match ]]; then | |
echo | |
echo " STOP THE PRESS!" | |
echo " You are trying to commit on the *$branch* branch." | |
echo " Surely you don't mean that?" | |
echo | |
echo " If you really do, force the commit by adding --no-verify to the command." | |
echo | |
exit 1 | |
fi |
This file contains hidden or 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/bash | |
# prevent failing stuff to be pushed | |
grunt test > /dev/null 2>&1 | |
if [ $? -ne 0 ]; then | |
echo | |
echo " OH SNAP!" | |
echo " You are trying to commit something which is not passing the tests." | |
echo " Surely you don't mean that?" | |
echo | |
echo " If you really do, force the commit by adding --no-verify to the command." | |
echo | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment