2020-06-10 04:20:15 +00:00
|
|
|
#!/bin/sh
|
2020-06-10 03:40:48 +00:00
|
|
|
|
|
|
|
PROTECTED_BRANCH="master"
|
2020-06-10 04:20:15 +00:00
|
|
|
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3)
|
2020-06-10 03:40:48 +00:00
|
|
|
|
2020-06-10 04:20:15 +00:00
|
|
|
if [ -n "$REMOTE_REF" ]; then
|
2020-07-14 10:51:50 +00:00
|
|
|
if [ "refs/heads/${PROTECTED_BRANCH}" == "$REMOTE_REF" ]; then
|
2020-07-14 10:53:22 +00:00
|
|
|
if [ "$TERM" == "dumb" ]; then
|
|
|
|
>&2 echo "Sorry, you are unable to push to master using a GUI client! Please use git CLI."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-06-10 04:20:15 +00:00
|
|
|
printf "%sYou're about to push to master, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
|
|
|
|
read -r PROCEED < /dev/tty
|
|
|
|
echo
|
|
|
|
|
|
|
|
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
|
|
|
|
echo "$(tput setaf 2)Brace yourself! Pushing to the master branch...$(tput sgr0)"
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
fi
|
2020-06-10 03:40:48 +00:00
|
|
|
|
2020-06-10 04:20:15 +00:00
|
|
|
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)"
|
2020-06-10 03:40:48 +00:00
|
|
|
echo
|
2020-06-10 04:20:15 +00:00
|
|
|
exit 1
|
2020-06-10 03:40:48 +00:00
|
|
|
fi
|
|
|
|
fi
|