- Rename post-commit-ots → post-commit - Rename pre-commit-ots → pre-commit - Remove legacy post-commit and pre-commit symlinks - Update install.sh and documentation - Simplified: only 2 hook files with standard names Hooks are now named exactly as git expects them, making manual installation more intuitive.
73 lines
2.1 KiB
Bash
Executable file
73 lines
2.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Git OpenTimestamp Hooks Installer
|
|
# Requires: opentimestamps-client (ots CLI)
|
|
|
|
set -e
|
|
|
|
REPO_PATH="${1:-.}"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
cd "$REPO_PATH"
|
|
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
echo "Error: not a git repository" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Check for ots CLI (required)
|
|
if ! command -v ots &> /dev/null; then
|
|
echo "Error: ots CLI not found" >&2
|
|
echo "" >&2
|
|
echo "OpenTimestamp client is required for full Bitcoin attestation." >&2
|
|
echo "Install with one of:" >&2
|
|
echo "" >&2
|
|
echo " # Recommended (isolated install)" >&2
|
|
echo " pipx install opentimestamps-client" >&2
|
|
echo "" >&2
|
|
echo " # Or with pip" >&2
|
|
echo " pip install opentimestamps-client" >&2
|
|
echo "" >&2
|
|
echo " # Or from source" >&2
|
|
echo " git clone https://github.com/opentimestamps/opentimestamps-client" >&2
|
|
echo " cd opentimestamps-client && pip install ." >&2
|
|
echo "" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "✓ Detected: ots CLI ($(ots --version))"
|
|
|
|
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
|
|
|
|
echo "Installing hooks to: $HOOKS_DIR"
|
|
|
|
# Copy hooks
|
|
cp "$SCRIPT_DIR/post-commit" "$HOOKS_DIR/post-commit"
|
|
cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
|
|
|
|
chmod +x "$HOOKS_DIR/post-commit" "$HOOKS_DIR/pre-commit"
|
|
|
|
echo "✓ Post-commit hook installed"
|
|
echo "✓ Pre-commit backfill hook installed"
|
|
|
|
# Setup .gitignore
|
|
GITIGNORE=".gitignore"
|
|
if [ ! -f "$GITIGNORE" ]; then
|
|
echo ".ots/.attestation-cache" > "$GITIGNORE"
|
|
echo "✓ Created .gitignore"
|
|
elif ! grep -q ".ots/.attestation-cache" "$GITIGNORE"; then
|
|
echo ".ots/.attestation-cache" >> "$GITIGNORE"
|
|
echo "✓ Updated .gitignore"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Configuration:"
|
|
echo " - Full Bitcoin attestation via remote calendars"
|
|
echo " - Proofs submitted to 4+ calendar servers"
|
|
echo " - Attestation available after ~10 min (Bitcoin confirmation)"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Make a test commit"
|
|
echo "2. Commit proofs: git add .ots/ && git commit -m 'Add OpenTimestamp proofs'"
|
|
echo ""
|
|
echo "To uninstall:"
|
|
echo " rm $HOOKS_DIR/post-commit $HOOKS_DIR/pre-commit"
|