feat(dossiers-ngi): sticky bar vs-parent loc-on-roots split plus/minus 45rem
This commit is contained in:
parent
da6f384399
commit
7397cddb83
6 changed files with 148 additions and 85 deletions
|
|
@ -258,6 +258,17 @@ def diff_numstat(repo: Path, a: str, b: str) -> tuple[int, int]:
|
|||
return plus, minus
|
||||
|
||||
|
||||
def empty_tree_oid(repo: Path) -> str:
|
||||
cp = git(repo, "hash-object", "-t", "tree", "/dev/null")
|
||||
return (cp.stdout or "").strip()
|
||||
|
||||
|
||||
def loc_at_tip(repo: Path, tip: str, empty: str) -> int:
|
||||
"""Text-file line count of tip vs the empty tree."""
|
||||
plus, _ = diff_numstat(repo, empty, tip)
|
||||
return plus
|
||||
|
||||
|
||||
def tip_commit_time(repo: Path, tip: str) -> str:
|
||||
"""Committer ISO time of tip (empty on failure)."""
|
||||
cp = git(repo, "log", "-1", "--format=%cI", tip, check=False)
|
||||
|
|
@ -564,10 +575,7 @@ 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_numstat(repo, main_tip, tip) for name, tip in tips.items()
|
||||
}
|
||||
empty = empty_tree_oid(repo)
|
||||
branches_out = []
|
||||
for row in rows:
|
||||
name = row["branch"]
|
||||
|
|
@ -593,11 +601,14 @@ 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; gray loc when no parent in tree
|
||||
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
|
||||
else:
|
||||
entry["loc"] = loc_at_tip(repo, row["tip"], empty)
|
||||
branches_out.append(entry)
|
||||
|
||||
payload = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue