forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pre-push hook to prevent accidental pushes to master
- Loading branch information
1 parent
c680f88
commit d3b8e4f
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
PROTECTED_BRANCH="master" | ||
REMOTE_REF=$(echo $HUSKY_GIT_STDIN | cut -d " " -f 3) | ||
|
||
if [[ "$REMOTE_REF" == *"$PROTECTED_BRANCH"* ]]; then | ||
printf "$(tput setaf 3)You're about to push to master, is that what you intended? [y/N]: $(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 | ||
|
||
echo "$(tput setaf 2)Push to master cancelled!$(tput sgr0)" | ||
echo | ||
exit 1 | ||
fi |
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