feat(dossiers-ngi): sticky bar + JSON diffstat vs parent tip
This commit is contained in:
parent
31af42538a
commit
27c7f4e37e
4 changed files with 32 additions and 31 deletions
|
|
@ -58,7 +58,7 @@ Per branch in JSON / sticky bar:
|
||||||
| `tip_time` | committer time of tip (`%cI`) |
|
| `tip_time` | committer time of tip (`%cI`) |
|
||||||
| `built_at` | when this edition freeze was written |
|
| `built_at` | when this edition freeze was written |
|
||||||
| `build_seconds` | wall time of that freeze |
|
| `build_seconds` | wall time of that freeze |
|
||||||
| `vs_main_plus` / `vs_main_minus` | `git diff --numstat` tip vs `main` tip (sticky bar +grün/−rot; omitted on `main`) |
|
| `vs_parent_plus` / `vs_parent_minus` | `git diff --numstat` tip vs parent tip (sticky bar +grün/−rot; omitted when no parent) |
|
||||||
|
|
||||||
Rebuild runs **only when** `.edition-tip` ≠ current tip (timer never forces).
|
Rebuild runs **only when** `.edition-tip` ≠ current tip (timer never forces).
|
||||||
Each run also: `git fetch --prune`, `worktree prune`, drop stale
|
Each run also: `git fetch --prune`, `worktree prune`, drop stale
|
||||||
|
|
|
||||||
|
|
@ -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]:
|
def diff_numstat(repo: Path, parent_tip: str, tip: str) -> tuple[int, int]:
|
||||||
"""Insertions/deletions of tip vs main tip (git diff --numstat)."""
|
"""Insertions/deletions of tip vs parent tip (git diff --numstat)."""
|
||||||
if not main_tip or not tip or main_tip == tip:
|
if not parent_tip or not tip or parent_tip == tip:
|
||||||
return 0, 0
|
return 0, 0
|
||||||
cp = git(repo, "diff", "--numstat", main_tip, tip, check=False)
|
cp = git(repo, "diff", "--numstat", main_tip, tip, check=False)
|
||||||
if cp.returncode != 0:
|
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)
|
sync_flask_alias(ed_root, tips)
|
||||||
|
|
||||||
tip_times = {name: tip_commit_time(repo, tip) for name, tip in tips.items()}
|
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 = []
|
branches_out = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
name = row["branch"]
|
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"]
|
entry["built_at"] = meta["built_at"]
|
||||||
if "build_seconds" in meta:
|
if "build_seconds" in meta:
|
||||||
entry["build_seconds"] = meta["build_seconds"]
|
entry["build_seconds"] = meta["build_seconds"]
|
||||||
# sticky bar: +grün / −rot vs main (omit on main itself)
|
# sticky bar: +grün / −rot vs parent tip; omit when no parent
|
||||||
if name != "main" and main_tip:
|
parent = row["parent"]
|
||||||
plus, minus = vs_main.get(name, (0, 0))
|
if parent and parent in tips:
|
||||||
entry["vs_main_plus"] = plus
|
plus, minus = diff_numstat(repo, tips[parent], row["tip"])
|
||||||
entry["vs_main_minus"] = minus
|
entry["vs_parent_plus"] = plus
|
||||||
|
entry["vs_parent_minus"] = minus
|
||||||
branches_out.append(entry)
|
branches_out.append(entry)
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,13 @@
|
||||||
if (buildSec != null && buildSec !== "")
|
if (buildSec != null && buildSec !== "")
|
||||||
parts.push(esc("build " + fmtBuildSec(buildSec)));
|
parts.push(esc("build " + fmtBuildSec(buildSec)));
|
||||||
if (builtAt) parts.push(esc("at " + shortTime(builtAt)));
|
if (builtAt) parts.push(esc("at " + shortTime(builtAt)));
|
||||||
// vs main: +grün / −rot (omit on main / when both zero absent)
|
// vs parent: +grün / −rot (omit when no parent)
|
||||||
var plus = row.vs_main_plus;
|
var plus = row.vs_parent_plus;
|
||||||
var minus = row.vs_main_minus;
|
var minus = row.vs_parent_minus;
|
||||||
if (plus != null || minus != null) {
|
if (row.parent && (plus != null || minus != null)) {
|
||||||
var p = plus == null ? 0 : Number(plus);
|
var p = plus == null ? 0 : Number(plus);
|
||||||
var m = minus == null ? 0 : Number(minus);
|
var m = minus == null ? 0 : Number(minus);
|
||||||
if (isFinite(p) && isFinite(m) && (p > 0 || m > 0 || row.branch !== "main")) {
|
if (isFinite(p) && isFinite(m)) {
|
||||||
parts.push(
|
parts.push(
|
||||||
'<span class="diff-plus">+' +
|
'<span class="diff-plus">+' +
|
||||||
esc(String(p)) +
|
esc(String(p)) +
|
||||||
|
|
@ -70,12 +70,14 @@
|
||||||
function rowTitle(row, buildSec) {
|
function rowTitle(row, buildSec) {
|
||||||
var tip = row.tip || "";
|
var tip = row.tip || "";
|
||||||
var tipTime = row.tip_time || "";
|
var tipTime = row.tip_time || "";
|
||||||
var plus = row.vs_main_plus;
|
var plus = row.vs_parent_plus;
|
||||||
var minus = row.vs_main_minus;
|
var minus = row.vs_parent_minus;
|
||||||
var vs = "";
|
var vs = "";
|
||||||
if (plus != null || minus != null) {
|
if (row.parent && (plus != null || minus != null)) {
|
||||||
vs =
|
vs =
|
||||||
" vs main +" +
|
" vs " +
|
||||||
|
row.parent +
|
||||||
|
" +" +
|
||||||
String(plus == null ? 0 : plus) +
|
String(plus == null ? 0 : plus) +
|
||||||
"/−" +
|
"/−" +
|
||||||
String(minus == null ? 0 : minus);
|
String(minus == null ? 0 : minus);
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,13 @@
|
||||||
if (buildSec != null && buildSec !== "")
|
if (buildSec != null && buildSec !== "")
|
||||||
parts.push(esc("build " + fmtBuildSec(buildSec)));
|
parts.push(esc("build " + fmtBuildSec(buildSec)));
|
||||||
if (builtAt) parts.push(esc("at " + shortTime(builtAt)));
|
if (builtAt) parts.push(esc("at " + shortTime(builtAt)));
|
||||||
// vs main: +grün / −rot (omit on main / when both zero absent)
|
// vs parent: +grün / −rot (omit when no parent)
|
||||||
var plus = row.vs_main_plus;
|
var plus = row.vs_parent_plus;
|
||||||
var minus = row.vs_main_minus;
|
var minus = row.vs_parent_minus;
|
||||||
if (plus != null || minus != null) {
|
if (row.parent && (plus != null || minus != null)) {
|
||||||
var p = plus == null ? 0 : Number(plus);
|
var p = plus == null ? 0 : Number(plus);
|
||||||
var m = minus == null ? 0 : Number(minus);
|
var m = minus == null ? 0 : Number(minus);
|
||||||
if (isFinite(p) && isFinite(m) && (p > 0 || m > 0 || row.branch !== "main")) {
|
if (isFinite(p) && isFinite(m)) {
|
||||||
parts.push(
|
parts.push(
|
||||||
'<span class="diff-plus">+' +
|
'<span class="diff-plus">+' +
|
||||||
esc(String(p)) +
|
esc(String(p)) +
|
||||||
|
|
@ -70,12 +70,14 @@
|
||||||
function rowTitle(row, buildSec) {
|
function rowTitle(row, buildSec) {
|
||||||
var tip = row.tip || "";
|
var tip = row.tip || "";
|
||||||
var tipTime = row.tip_time || "";
|
var tipTime = row.tip_time || "";
|
||||||
var plus = row.vs_main_plus;
|
var plus = row.vs_parent_plus;
|
||||||
var minus = row.vs_main_minus;
|
var minus = row.vs_parent_minus;
|
||||||
var vs = "";
|
var vs = "";
|
||||||
if (plus != null || minus != null) {
|
if (row.parent && (plus != null || minus != null)) {
|
||||||
vs =
|
vs =
|
||||||
" vs main +" +
|
" vs " +
|
||||||
|
row.parent +
|
||||||
|
" +" +
|
||||||
String(plus == null ? 0 : plus) +
|
String(plus == null ? 0 : plus) +
|
||||||
"/−" +
|
"/−" +
|
||||||
String(minus == null ? 0 : minus);
|
String(minus == null ? 0 : minus);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue