#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# check if main stream (stdout and stderr) are attached to the terminal
if [ -t 1 ] && [ -t 2 ]; then
    # Allows us to read user input below, redirects script's input to the terminal.
    exec < /dev/tty
fi

PROTECTED_BRANCH_LIST="develop trunk"
CURRENT_BRANCH=$(git branch --show-current)

if echo "$PROTECTED_BRANCH_LIST" | grep -q -w "$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