#!/bin/bash
# Set up git hooks for slack5-1770606136
# Run this after cloning the repository

set -e

GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"

echo "Setting up git hooks for slack5-1770606136..."

# Ensure we're in a git repo
if [ ! -d "$PROJECT_ROOT/.git" ]; then
    echo "Error: Not a git repository"
    exit 1
fi

# Ensure .githooks directory exists
if [ ! -d "$PROJECT_ROOT/.githooks" ]; then
    echo "Error: .githooks directory not found"
    exit 1
fi

# Configure git to use .githooks
git config core.hooksPath .githooks

# Make hooks executable
chmod +x "$PROJECT_ROOT/.githooks/"*

echo -e "${GREEN}Git hooks installed successfully!${NC}"
echo ""
echo "Installed hooks:"
echo "  - pre-commit: Code quality checks (formatting, linting)"
echo "  - commit-msg: Conventional commit validation"
echo ""
echo -e "${YELLOW}Note:${NC} You may need to install these tools for full functionality:"
echo "  - goimports: go install golang.org/x/tools/cmd/goimports@latest"
echo "  - golangci-lint: brew install golangci-lint"
echo "  - prettier: npm install -g prettier (or use per-project)"
echo "  - eslint: npm install -g eslint (or use per-project)"
