diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 00000000000..3dc4fa4bcd0 --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,16 @@ +#!/bin/bash +. "$(dirname "$0")/_/husky.sh" + +# Allows us to read user input below, redirects script's input to the terminal. +exec < /dev/tty + +PROTECTED_BRANCH=("develop" "trunk") +CURRENT_BRANCH=$(git branch --show-current) + +if [[ " ${PROTECTED_BRANCH[@]} " =~ " ${CURRENT_BRANCH} " ]]; then + read -p "$CURRENT_BRANCH is a protected branch. Are you sure you want to push? (y/n): " confirmation + if [ "$confirmation" != "y" ]; then + echo "Push aborted" + exit 1 + fi +fi \ No newline at end of file diff --git a/changelog/avoid-accidental-push-to-develop b/changelog/avoid-accidental-push-to-develop new file mode 100644 index 00000000000..b1a0fee6648 --- /dev/null +++ b/changelog/avoid-accidental-push-to-develop @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Dev: additional check when pushing to protected branches.