feat(dossiers-ngi): inject-editions-bar.sh for freeze HTML missing include

This commit is contained in:
Hernâni Marques 2026-09-30 22:25:38 +02:00
parent 27c7f4e37e
commit 52e5c1d328
No known key found for this signature in database
9 changed files with 218 additions and 46 deletions

View file

@ -239,7 +239,7 @@ 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)
cp = git(repo, "diff", "--numstat", parent_tip, tip, check=False)
if cp.returncode != 0:
return 0, 0
plus = minus = 0
@ -392,13 +392,19 @@ def run_freeze(work: Path, branch: str, slug: str) -> None:
def inject_bar(edition_dir: Path) -> None:
if not INJECT.is_file():
print(f"WARN: inject script missing: {INJECT}", file=sys.stderr)
return
subprocess.run(
cp = subprocess.run(
[sys.executable, str(INJECT), str(edition_dir)],
check=False,
capture_output=True,
text=True,
)
if cp.stdout:
print(cp.stdout, end="" if str(cp.stdout).endswith("\n") else "\n", file=sys.stderr)
if cp.returncode != 0:
err = (cp.stderr or "").strip()[:300]
print(f"WARN: inject_bar {edition_dir}: {err}", file=sys.stderr)
def rebuild_edition(repo: Path, branch: str, tip: str, editions: Path) -> dict:
@ -425,6 +431,7 @@ def rebuild_edition(repo: Path, branch: str, tip: str, editions: Path) -> dict:
cp = git(repo, "worktree", "add", "--detach", str(wt), tip, check=False)
if cp.returncode != 0:
ensure_placeholder(editions, slug, tip)
inject_bar(dest)
return {
"status": f"error:worktree:{cp.stderr.strip()[:200]}",
"seconds": round(time.perf_counter() - t0, 3),
@ -434,6 +441,7 @@ def rebuild_edition(repo: Path, branch: str, tip: str, editions: Path) -> dict:
build = wt / "website" / "build"
if not build.is_dir():
ensure_placeholder(editions, slug, tip)
inject_bar(dest)
return {"status": "error:no-build", "seconds": round(time.perf_counter() - t0, 3)}
dest.mkdir(parents=True, exist_ok=True)
@ -462,6 +470,7 @@ def rebuild_edition(repo: Path, branch: str, tip: str, editions: Path) -> dict:
return {"status": "built", "seconds": secs}
except Exception as exc: # noqa: BLE001 — hourly must continue
ensure_placeholder(editions, slug, tip)
inject_bar(dest)
return {
"status": f"error:{type(exc).__name__}:{exc}",
"seconds": round(time.perf_counter() - t0, 3),