#!/bin/sh
# Reject any push that would create, update or delete main on the remote, however the
# command is spelled (bare `git push`, HEAD:main, +main, refs/heads/main, --all, --mirror).
# Only a human merges into main, through a PR in Gitea.
while read -r local_ref local_sha remote_ref remote_sha; do
  if [ "$remote_ref" = "refs/heads/main" ]; then
    echo "pre-push: pushing to main is not allowed; push a branch and open a PR instead." >&2
    exit 1
  fi
done
exit 0
