Make pre-push compatible with multiple environments
This commit is contained in:
parent
d3b8e4f66a
commit
feada5e092
|
@ -1,20 +1,22 @@
|
||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
PROTECTED_BRANCH="master"
|
PROTECTED_BRANCH="master"
|
||||||
REMOTE_REF=$(echo $HUSKY_GIT_STDIN | cut -d " " -f 3)
|
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3)
|
||||||
|
|
||||||
if [[ "$REMOTE_REF" == *"$PROTECTED_BRANCH"* ]]; then
|
if [ -n "$REMOTE_REF" ]; then
|
||||||
printf "$(tput setaf 3)You're about to push to master, is that what you intended? [y/N]: $(tput sgr0)"
|
if [ -z "${REMOTE_REF##*$PROTECTED_BRANCH*}" ]; then
|
||||||
read -r PROCEED < /dev/tty
|
printf "%sYou're about to push to master, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
|
||||||
echo
|
read -r PROCEED < /dev/tty
|
||||||
|
|
||||||
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
|
|
||||||
echo "$(tput setaf 2)Brace yourself! Pushing to the master branch...$(tput sgr0)"
|
|
||||||
echo
|
echo
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)"
|
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
|
||||||
echo
|
echo "$(tput setaf 2)Brace yourself! Pushing to the master branch...$(tput sgr0)"
|
||||||
exit 1
|
echo
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue