guanghu-ice-heart/server-tools/code-channel-snapshot-admission/pre-receive

12 lines
403 B
Shell

#!/bin/sh
set -eu
validator="$(dirname "$0")/validate-public-snapshot-at-commit.js"
while read -r old_value new_value ref_name; do
[ "$ref_name" = "refs/heads/main" ] || continue
[ "$new_value" = "0000000000000000000000000000000000000000" ] && {
echo "REPO-012 main deletion is forbidden" >&2
exit 1
}
node "$validator" --git-dir "$(git rev-parse --git-dir)" --commit "$new_value"
done