#!/bin/bash # Install git hooks from .githooks directory HOOKS_DIR=".githooks" GIT_HOOKS_DIR=".git/hooks" # Ensure .git/hooks directory exists if [ ! -d "$GIT_HOOKS_DIR" ]; then echo "Error: .git/hooks directory not found. Are you in a git repository?" exit 1 fi # Copy all hooks from .githooks to .git/hooks for hook in "$HOOKS_DIR"/*; do # Skip this installation script if [ "$(basename "$hook")" = "install-hooks.sh" ] || [ "$(basename "$hook")" = "README.md" ]; then continue fi if [ -f "$hook" ]; then hook_name=$(basename "$hook") echo "Installing $hook_name..." cp "$hook" "$GIT_HOOKS_DIR/$hook_name" chmod +x "$GIT_HOOKS_DIR/$hook_name" echo "✓ $hook_name installed" fi done echo "" echo "All hooks installed successfully!"