2020-06-10 04:20:15 +00:00
|
|
|
#!/bin/sh
|
2020-06-10 03:40:48 +00:00
|
|
|
|
2021-02-25 23:51:14 +00:00
|
|
|
PROTECTED_BRANCH="trunk"
|
2022-03-30 07:44:51 +00:00
|
|
|
CURRENT_BRANCH=$(git branch --show-current)
|
|
|
|
if [ $PROTECTED_BRANCH = $CURRENT_BRANCH ]; then
|
|
|
|
if [ "$TERM" = "dumb" ]; then
|
|
|
|
>&2 echo "Sorry, you are unable to push to $PROTECTED_BRANCH using a GUI client! Please use git CLI."
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-10 04:20:15 +00:00
|
|
|
|
2022-03-30 07:44:51 +00:00
|
|
|
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
|
|
|
|
echo
|
2020-06-10 03:40:48 +00:00
|
|
|
|
2022-03-30 07:44:51 +00:00
|
|
|
if [ "$(echo "${PROCEED:-n}" | tr "[:upper:]" "[:lower:]")" = "y" ]; then
|
|
|
|
echo "$(tput setaf 2)Brace yourself! Pushing to the $PROTECTED_BRANCH branch...$(tput sgr0)"
|
2020-06-10 03:40:48 +00:00
|
|
|
echo
|
2022-03-30 07:44:51 +00:00
|
|
|
exit 0
|
2020-06-10 03:40:48 +00:00
|
|
|
fi
|
2022-03-30 07:44:51 +00:00
|
|
|
|
|
|
|
echo "$(tput setaf 2)Push to $PROTECTED_BRANCH cancelled!$(tput sgr0)"
|
|
|
|
echo
|
|
|
|
exit 1
|
2020-06-10 03:40:48 +00:00
|
|
|
fi
|
2022-07-20 13:09:48 +00:00
|
|
|
|
2022-08-24 15:15:22 +00:00
|
|
|
pnpm exec syncpack -- list-mismatches
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "You must sync the dependencies listed above before you can push this branch."
|
|
|
|
echo "This can usually be accomplished automatically by updating the pinned version in `.syncpackrc` and then running \`pnpm run sync-dependencies\`."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-02-20 19:42:44 +00:00
|
|
|
# Ensure both branches are tracked or check-changelogger-use will fail. Note we pass hooksPath
|
|
|
|
# to avoid running the pre-commit hook.
|
|
|
|
git -c core.hooksPath=/dev/null checkout $PROTECTED_BRANCH --quiet
|
|
|
|
git -c core.hooksPath=/dev/null checkout $CURRENT_BRANCH --quiet
|
2022-09-19 00:58:52 +00:00
|
|
|
|
2022-08-02 20:24:20 +00:00
|
|
|
php tools/monorepo/check-changelogger-use.php $PROTECTED_BRANCH $CURRENT_BRANCH
|