Created
September 27, 2021 10:47
-
-
Save kumarvimal/2f83f3abe3fdce16342e029f9769c523 to your computer and use it in GitHub Desktop.
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 | |
# how to use this: | |
# put the content to path : `.git/hooks/pre-push` | |
# make is excecutable: `chmod +x .git/hooks/pre-push` | |
# reinitialize the git: `git init` | |
# shellcheck disable=SC2162 | |
# shellcheck disable=SC2034 | |
if read local_ref local_sha remote_ref remote_sha; then | |
if [[ "$remote_ref" == *"_production"* ]]; then | |
echo -en "\033[1;33mYou're about to push to production, is that what you intended? [y|n] \033[0m" | |
echo -en "\033[1m" | |
read -n 1 -r < /dev/tty | |
echo -en "\033[0m" | |
echo | |
if echo "$REPLY" | grep -E '^[Yy]$' > /dev/null; then | |
exit 0 # push will execute | |
fi | |
exit 1 # push will not execute | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment