mirror of
https://github.com/sinanyuntu/trade-message-center.git
synced 2026-09-17 13:22:11 +08:00
27 lines
664 B
Bash
27 lines
664 B
Bash
#!/usr/bin/env sh
|
|
|
|
set -e
|
|
|
|
zero_object_id=0000000000000000000000000000000000000000
|
|
|
|
while IFS=' ' read -r local_ref local_object_id remote_ref remote_object_id
|
|
do
|
|
if [ "$remote_ref" != "refs/heads/main" ]; then
|
|
continue
|
|
fi
|
|
|
|
if [ "$local_object_id" = "$zero_object_id" ]; then
|
|
echo "拒绝推送:禁止删除远端 main。" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$remote_object_id" = "$zero_object_id" ]; then
|
|
continue
|
|
fi
|
|
|
|
if ! git merge-base --is-ancestor "$remote_object_id" "$local_object_id"; then
|
|
echo "拒绝推送:远端 main 只允许快进更新,禁止强制推送。" >&2
|
|
exit 1
|
|
fi
|
|
done
|