#!/bin/bash # Setup script to install git hooks # Run this after cloning the repository set -e SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" GIT_HOOKS_DIR="$SCRIPT_DIR/.git/hooks" SOURCE_HOOKS_DIR="$SCRIPT_DIR/git-hooks" # Check if we're in a git repository if [ ! -d "$SCRIPT_DIR/.git" ]; then echo "Error: Not in a git repository. Please run this from the repository root." exit 1 fi echo "Setting up git hooks..." # Create .git/hooks directory if it doesn't exist mkdir -p "$GIT_HOOKS_DIR" # Copy pre-push hook if [ -f "$SOURCE_HOOKS_DIR/pre-push" ]; then cp "$SOURCE_HOOKS_DIR/pre-push" "$GIT_HOOKS_DIR/pre-push" chmod +x "$GIT_HOOKS_DIR/pre-push" echo "✓ Installed pre-push hook" else echo "✗ pre-push hook not found in git-hooks/" exit 1 fi # Verify installation if [ -x "$GIT_HOOKS_DIR/pre-push" ]; then echo "✓ Hook is executable and ready" else echo "✗ Hook installation verification failed" exit 1 fi echo "" echo "Git hooks installed successfully!" echo "PDFs will be automatically generated before each push." echo "" echo "To test the hook, try: git push --dry-run"