Last active
October 9, 2017 05:17
-
-
Save wx257osn2/3c9cd405113fc5d0d4d5d29dfcc9f83e to your computer and use it in GitHub Desktop.
Warning script about commit to master branch(git pre-commit hook)
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 | |
mkdir -p ~/.git_template/hooks | |
git config --global init.templatedir ~/.git_template | |
cat pre-commit >> ~/.git_template/hooks/pre-commit | |
chmod +x ~/.git_template/hooks/pre-commit |
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 | |
MASTER='master' | |
yasuno () { | |
printf "\e[33;1m${1} \e[37;1m[y/N]: \e[m" | |
exec < /dev/tty | |
read yn | |
case $yn in | |
[yY]*) return 0 ;; | |
*) return 1 ;; | |
esac | |
} | |
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
if test $CURRENT_BRANCH = $MASTER; then | |
yasuno "WARNING: You are on the '$MASTER' branch now.\nDo you REALLY want to commit to the $MASTER branch?" | |
exit $? | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment