50 lines
1.3 KiB
Bash
Executable file
50 lines
1.3 KiB
Bash
Executable file
#!/bin/bash
|
|
# Git OpenTimestamp Hooks Installer
|
|
# Copies self-contained hooks to git repository
|
|
|
|
set -e
|
|
|
|
REPO_PATH="${1:-.}"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
cd "$REPO_PATH"
|
|
|
|
# Verify we're in a git repository
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
echo "Error: not a git repository" >&2
|
|
exit 1
|
|
fi
|
|
|
|
HOOKS_DIR="$(git rev-parse --git-dir)/hooks"
|
|
|
|
echo "Installing OpenTimestamp hooks to: $HOOKS_DIR"
|
|
|
|
# Copy hooks
|
|
cp "$SCRIPT_DIR/post-commit" "$HOOKS_DIR/post-commit"
|
|
cp "$SCRIPT_DIR/pre-commit" "$HOOKS_DIR/pre-commit"
|
|
|
|
# Make executable
|
|
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 "" >> "$GITIGNORE"
|
|
echo ".ots/.attestation-cache" >> "$GITIGNORE"
|
|
echo "✓ Updated .gitignore"
|
|
fi
|
|
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Make a test commit to verify hooks work"
|
|
echo "2. Commit the .ots/ directory: git add .ots/"
|
|
echo "3. Commit with message: git commit -m 'Add OpenTimestamp proofs'"
|
|
echo ""
|
|
echo "To uninstall:"
|
|
echo " rm $HOOKS_DIR/post-commit $HOOKS_DIR/pre-commit"
|