git-ots/scripts/pre-commit-backfill

32 lines
1 KiB
Bash
Executable file

#!/bin/bash
# Pre-commit hook: backfill proofs for all commits before creating new commit
# This ensures all historical commits have attested proofs
set -e
# Get the directory where this hook is installed
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Find the backfill-proofs.sh script
BACKFILL_SCRIPT=""
if [ -f "$SCRIPT_DIR/backfill-proofs.sh" ]; then
BACKFILL_SCRIPT="$SCRIPT_DIR/backfill-proofs.sh"
elif [ -f ".git/hooks/backfill-proofs.sh" ]; then
BACKFILL_SCRIPT=".git/hooks/backfill-proofs.sh"
elif [ -f "backfill-proofs.sh" ]; then
BACKFILL_SCRIPT="./backfill-proofs.sh"
elif [ -f "$HOME/.openclaw/workspace/skills/git-ots-hook/scripts/backfill-proofs.sh" ]; then
BACKFILL_SCRIPT="$HOME/.openclaw/workspace/skills/git-ots-hook/scripts/backfill-proofs.sh"
else
# Silently skip if backfill script not found
exit 0
fi
chmod +x "$BACKFILL_SCRIPT"
echo "[ots] Backfilling proofs before commit..."
"$BACKFILL_SCRIPT" .
echo "[ots] Ready to commit"