
#!/usr/bin/env bash

set -e

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

echo "Installing git hooks..."

# Create .git/hooks directory if it doesn't exist
mkdir -p "$GIT_HOOKS_DIR"

# Symlink all hooks from .githooks to .git/hooks
for hook in "$HOOKS_DIR"/*; do
    hook_name=$(basename "$hook")
    target="$GIT_HOOKS_DIR/$hook_name"
    
    # Remove existing hook or symlink
    [ -e "$target" ] && rm "$target"
    
    # Create symlink
    ln -s "../../$HOOKS_DIR/$hook_name" "$target"
    chmod +x "$hook"
    
    echo "✅ Installed $hook_name"
done

echo "Git hooks installed successfully!"
