Fix bin/post-merge.sh & bin/pre-push.sh

This commit is contained in:
Chi-Hsuan Huang 2022-03-30 15:44:51 +08:00
parent ae44908f33
commit 7c4c98c91d
3 changed files with 22 additions and 23 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh
. "$(dirname "$0")/_/husky.sh" . "$(dirname "$0")/_/husky.sh"
./bin/post-push.sh ./bin/pre-push.sh

View File

@ -9,5 +9,7 @@ runOnChange() {
fi fi
} }
runOnChange "package-lock.json" "pnpm install" runOnChange "pnpm-lock.yaml" "pnpm install"
runOnChange "composer.lock" "SKIP_UPDATE_TEXTDOMAINS=true composer install" runOnChange "composer.lock" "SKIP_UPDATE_TEXTDOMAINS=true composer install"
runOnChange "plugins/woocommerce/composer.lock" "SKIP_UPDATE_TEXTDOMAINS=true composer --working-dir=plugins/woocommerce install"
runOnChange "plugins/woocommerce-beta-tester/composer.lock" "SKIP_UPDATE_TEXTDOMAINS=true composer --working-dir=plugins/woocommerce-beta-tester install"

View File

@ -1,27 +1,24 @@
#!/bin/sh #!/bin/sh
PROTECTED_BRANCH="trunk" PROTECTED_BRANCH="trunk"
REMOTE_REF=$(echo "$HUSKY_GIT_STDIN" | cut -d " " -f 3) CURRENT_BRANCH=$(git branch --show-current)
if [ $PROTECTED_BRANCH = $CURRENT_BRANCH ]; then
if [ -n "$REMOTE_REF" ]; then
if [ "refs/heads/${PROTECTED_BRANCH}" = "$REMOTE_REF" ]; then
if [ "$TERM" = "dumb" ]; then if [ "$TERM" = "dumb" ]; then
>&2 echo "Sorry, you are unable to push to trunk using a GUI client! Please use git CLI." >&2 echo "Sorry, you are unable to push to $PROTECTED_BRANCH using a GUI client! Please use git CLI."
exit 1 exit 1
fi fi
printf "%sYou're about to push to trunk, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)" printf "%sYou're about to push to $PROTECTED_BRANCH, is that what you intended? [y/N]: %s" "$(tput setaf 3)" "$(tput sgr0)"
read -r PROCEED < /dev/tty read -r PROCEED < /dev/tty
echo echo
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
echo "$(tput setaf 2)Brace yourself! Pushing to the trunk branch...$(tput sgr0)" echo "$(tput setaf 2)Brace yourself! Pushing to the $PROTECTED_BRANCH branch...$(tput sgr0)"
echo echo
exit 0 exit 0
fi fi
echo "$(tput setaf 2)Push to trunk cancelled!$(tput sgr0)" echo "$(tput setaf 2)Push to $PROTECTED_BRANCH cancelled!$(tput sgr0)"
echo echo
exit 1 exit 1
fi fi
fi