#!/usr/bin/env sh
remote_name="$1"
remote_url="$2"
if [ "$ALLOW_PROTECTED_PUSH" = "1" ]; then
echo "pre-push: protected branch guard bypassed (ALLOW_PROTECTED_PUSH=1)."
exit 0
fi
while read -r local_ref local_sha remote_ref remote_sha; do
case "$remote_ref" in
refs/heads/staging|refs/heads/main|refs/heads/master)
echo "pre-push: blocked push to protected branch '$remote_ref' on '$remote_name'."
echo "Use a feature branch and open a PR instead."
echo "To bypass intentionally, set ALLOW_PROTECTED_PUSH=1 for this push."
exit 1
;;
esac
done
echo "pre-push: OK ($remote_name -> $remote_url)."