git-ots/hooks/install.sh
Otto b4e2eb3c12 Remove Node.js hooks, require ots CLI only
- Delete hooks/post-commit-node (local proofs only, no attestation)
- Delete hooks/pre-commit-node (no upgrade support)
- Update hooks/install.sh to require ots CLI (no fallback)
- Update documentation with clear ots CLI requirement
- Add prominent warnings about Node.js limitations

Rationale: The @opentimestamps/ots Node.js package only creates
local proofs without calendar submission or Bitcoin attestation.
For tamper-evident timestamps, ots CLI is the only complete
implementation. No partial/fallback implementations.
2026-03-08 00:50:32 +01:00

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 ots hooks
cp "$SCRIPT_DIR/post-commit-ots" "$HOOKS_DIR/post-commit"
cp "$SCRIPT_DIR/pre-commit-ots" "$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"