V1.4 de l'amélioration du suivi des issues

This commit is contained in:
Mathis 2026-07-12 18:41:25 +02:00
parent f26ff968f3
commit c14e2fb7e3
6 changed files with 47 additions and 62 deletions

View file

@ -18,7 +18,9 @@ if not FORGEJO_TOKEN or not FORGEJO_OWNER or not FORGEJO_REPO:
raise RuntimeError("Forgejo variables (FORGEJO_TOKEN, FORGEJO_OWNER, FORGEJO_REPO) must be set.")
# Fichiers de persistance mis à jour pour Forgejo
ISSUE_TRACK_FILE = os.path.join(os.path.dirname(__file__), "forgejo_issues.json")
PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
ISSUE_TRACK_FILE = os.path.join(PROJECT_ROOT, "data", "forgejo_issues.json")
LEGACY_ISSUE_TRACK_FILE = os.path.join(PROJECT_ROOT, "commandes", "forgejo_issues.json")
def load_issue_tracking() -> Dict[str, Any]:
tracking = {}
@ -27,12 +29,26 @@ def load_issue_tracking() -> Dict[str, Any]:
with open(ISSUE_TRACK_FILE, "r", encoding="utf-8") as f:
tracking = json.load(f)
except Exception as e:
print(f"⚠️ Erreur chargement forgejo_issues.json: {e}")
print(f"⚠️ Erreur chargement forgejo_issues.json dans data/: {e}")
if not tracking and os.path.exists(LEGACY_ISSUE_TRACK_FILE):
try:
with open(LEGACY_ISSUE_TRACK_FILE, "r", encoding="utf-8") as f:
tracking = json.load(f)
print(f"Migration: Chargé forgejo_issues.json depuis {LEGACY_ISSUE_TRACK_FILE}")
save_issue_tracking(tracking)
except Exception as e:
print(f"⚠️ Erreur chargement ancien forgejo_issues.json: {e}")
return tracking
def save_issue_tracking(data: Dict[str, Any]) -> None:
with open(ISSUE_TRACK_FILE, "w", encoding="utf-8") as f:
os.makedirs(os.path.dirname(ISSUE_TRACK_FILE), exist_ok=True)
temp_file = f"{ISSUE_TRACK_FILE}.tmp"
with open(temp_file, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=2)
os.replace(temp_file, ISSUE_TRACK_FILE)
class ForgejoIntegration(commands.Cog):
"""Cog fournissant des commandes slash pour créer des tickets sur Forgejo et notifier les utilisateurs."""