#!/bin/sh
# RepoMap auto-update hook (post-merge)
# This hook runs after git pull/merge

# Check if repomap is available
if ! command -v repomap >/dev/null 2>&1; then
    exit 0
fi

# Check if .repomap directory exists (project is initialized)
if [ ! -d ".repomap" ]; then
    exit 0
fi

# Check if any C# files changed
CHANGED=$(git diff --name-only HEAD@{1} HEAD 2>/dev/null | grep -E "\.cs$" | head -1)

if [ -n "$CHANGED" ]; then
    echo "[RepoMap] C# files changed, updating repo map..."
    repomap generate --notify
fi
