#!/bin/bash

REPO_ROOT=$(git rev-parse --show-toplevel)
SCRIPT="${REPO_ROOT}/.githooks/generate_semantic_report.py"
REPORT="${REPO_ROOT}/logs/semantic_impact_report.txt"

if [ -f "$SCRIPT" ]; then
    cd "$REPO_ROOT"
    echo ""
    echo "🔍 SEMANTIK ETKI RAPORU (commit sonrasi):"
    echo "─────────────────────────────────────────────"
    python3 "$SCRIPT" --mode last | tee "$REPORT"
    RESULT=${PIPESTATUS[0]}

    if [ $RESULT -ne 0 ]; then
        echo ""
        echo "⚠️  Yukarida BLOKE EDIEN risk seviyesi tespit edildi. Commit tamamlanmistir;"
        echo "   ama ilgili modüllerin doğru çalışıp çalışmadığını `cargo check --workspace` ile kontrol edin."
        echo ""
    fi
fi

exit 0