#!/bin/bash
# Setup script to install git hooks
# Run this once after cloning the repository

set -e

HOOKS_DIR=".githooks"
GIT_HOOKS_DIR=".git/hooks"

if [ ! -d "$HOOKS_DIR" ]; then
    echo "❌ Error: $HOOKS_DIR directory not found"
    echo "Run this script from the repository root"
    exit 1
fi

echo "🔧 Setting up git hooks..."

# Make hooks executable
chmod +x "$HOOKS_DIR"/*

# Create symlinks
for hook in pre-commit pre-push; do
    if [ -f "$HOOKS_DIR/$hook" ]; then
        ln -sf "../../$HOOKS_DIR/$hook" "$GIT_HOOKS_DIR/$hook"
        echo "  ✓ Installed $hook hook"
    fi
done

echo "✅ Git hooks installed successfully!"
echo ""
echo "Hooks installed:"
echo "  - pre-commit: Formatting checks"
echo "  - pre-push: Full validation (clippy, tests, build)"

