Files
hcie-rust-v3.05/.githooks/semantic_analyzer.py
T
2026-07-09 02:59:53 +03:00

54 lines
2.1 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
import sys
import json
import subprocess
import os
def load_manifest():
with open("project_manifest.json", "r") as f:
return json.load(f)
def main():
changed_files = sys.argv[1].split('\n')
manifest = load_manifest()
critical_targets = set()
high_risk_change = False
for changed_file in changed_files:
if not changed_file.strip(): continue
files = manifest.get("files", []) if isinstance(manifest, dict) else manifest
for entry in files:
if entry.get("file_path", "") in changed_file:
print(f"⚠️ [UYARI] Değişiklik yapılan modül: {entry['file_path']}")
print(f" Açıklama: {entry['description']}")
print(f" Patlama Yarıçapı (Blast Radius): {entry['blast_radius']}")
if entry["blast_radius"] == "HIGH":
high_risk_change = True
for dep in entry.get("semantic_dependencies", []):
critical_targets.add((dep["target_file"], dep["impact_description"]))
if critical_targets:
os.makedirs("logs", exist_ok=True)
print("\n🚨 BU DEĞİŞİKLİKTEN ETKİLENEBİLECEK ÜCRA KÖŞELER VE ÖZELLİKLER:")
with open("logs/semantic_impact_report.txt", "w") as log:
log.write("=== SEMANTIK ETKI VE RISK RAPORU ===\n\n")
for target, reason in critical_targets:
report_line = f"- ETKİLENEN MODÜL: {target}\n RİSK NEDENİ: {reason}\n"
print(report_line)
log.write(report_line + "\n")
if high_risk_change:
print("🔄 Yüksek riskli alan değiştiği için Rust entegrasyon testleri zorunlu olarak çalıştırılıyor...")
result = subprocess.run("cargo test --all-features", shell=True)
if result.returncode != 0:
print("❌ Entegrasyon testleri başarısız oldu! Özellik kaybı var.")
sys.exit(1)
sys.exit(0)
if __name__ == "__main__":
main()