Last active
April 6, 2017 07:57
-
-
Save shabith/653a29ed1e9835e71fb0a4662523cf85 to your computer and use it in GitHub Desktop.
git hook with confirmation message
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/sh | |
# https://gist.github.com/shabith/653a29ed1e9835e71fb0a4662523cf85 | |
# git hook with confimation message | |
# this pre-push git hook will show a confirmation message and according to the answer (y or n) by user it will proceed or exit. | |
# Please note that this has been tested only in OSX terminal | |
# Allow us to read user input below, assigns stdin to keyboard | |
exec < /dev/tty | |
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ "master" = $branch ]; then | |
while true; do | |
echo "\n"; | |
read -p "๐จ ๐ฎ Did you merge with the upstream/master branch? (Y/n) " yn | |
if [ "$yn" = "" ]; then | |
yn='N' | |
fi | |
case $yn in | |
[Nn] ) echo "\n๐ โ Please merge with upstream/master branch before pushing to orgin/master. Thanks!\n"; exit 1;; | |
[Yy] ) echo "\n๐๐ฝ All good then. Thanks!\n"; break; exit 0;; | |
* ) echo "\n๐ Please answer y or n for Yes ๐๐ฝ or No ๐๐ฝ \n"; exit 1;; | |
esac | |
done | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment