feat/dossiers-ngi: sticky bar + JSON diffstat vs parent tip

This commit is contained in:
Hernâni Marques 2026-09-30 22:07:06 +02:00
parent c2bf7a4263
commit b24dd17ee9
No known key found for this signature in database
4 changed files with 32 additions and 31 deletions

View file

@ -235,9 +235,9 @@ def tip_recorded(editions: Path, slug: str) -> str:
def diff_vs_main(repo: Path, main_tip: str, tip: str) -> tuple[int, int]:
"""Insertions/deletions of tip vs main tip (git diff --numstat)."""
if not main_tip or not tip or main_tip == tip:
def diff_numstat(repo: Path, parent_tip: str, tip: str) -> tuple[int, int]:
"""Insertions/deletions of tip vs parent tip (git diff --numstat)."""
if not parent_tip or not tip or parent_tip == tip:
return 0, 0
cp = git(repo, "diff", "--numstat", main_tip, tip, check=False)
if cp.returncode != 0:
@ -555,10 +555,6 @@ def build_payload(repo: Path, tips: dict[str, str], rebuild: bool) -> dict:
sync_flask_alias(ed_root, tips)
tip_times = {name: tip_commit_time(repo, tip) for name, tip in tips.items()}
main_tip = tips.get("main", "")
vs_main = {
name: diff_vs_main(repo, main_tip, tip) for name, tip in tips.items()
}
branches_out = []
for row in rows:
name = row["branch"]
@ -584,11 +580,12 @@ def build_payload(repo: Path, tips: dict[str, str], rebuild: bool) -> dict:
entry["built_at"] = meta["built_at"]
if "build_seconds" in meta:
entry["build_seconds"] = meta["build_seconds"]
# sticky bar: +grün / −rot vs main (omit on main itself)
if name != "main" and main_tip:
plus, minus = vs_main.get(name, (0, 0))
entry["vs_main_plus"] = plus
entry["vs_main_minus"] = minus
# sticky bar: +grün / −rot vs parent tip; omit when no parent
parent = row["parent"]
if parent and parent in tips:
plus, minus = diff_numstat(repo, tips[parent], row["tip"])
entry["vs_parent_plus"] = plus
entry["vs_parent_minus"] = minus
branches_out.append(entry)
payload = {