Dough Git

commit

Logging

commit
b86bb12dd00aba35e285e90cf25d99736d2abfa3
author
Clove Twilight <[email protected]>
date
2026-09-17 16:27

diff --git a/package-lock.json b/package-lock.json
index 26badd7..08d85cc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "dough-git",
-  "version": "0.1.0",
+  "version": "1.0.0",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "dough-git",
-      "version": "0.1.0",
+      "version": "1.0.0",
       "dependencies": {
         "@hono/node-server": "^2.1.1",
         "hono": "^4.13.7",
@@ -819,9 +819,9 @@
       }
     },
     "node_modules/@types/node": {
-      "version": "26.5.0",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-26.5.0.tgz",
-      "integrity": "sha512-dVSGpriSoCgz8WnDNTuSSuSv1PC/ALXihO4ulRZt7Md8k9mlbdin3lGOcDE8SnWOgf513ByWlXd7BK4azmyg/A==",
+      "version": "26.6.1",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.1.tgz",
+      "integrity": "sha512-VqGJBMCtdhqkBUCcBLvywI0NJ+KLuVzgNnlBUNFOQjqVxzo2lxLUNg1DSey8+u2u6ktswSAxg+s68QLzWHNOuA==",
       "dev": true,
       "license": "MIT",
       "dependencies": {
@@ -1256,9 +1256,9 @@
       }
     },
     "node_modules/baseline-browser-mapping": {
-      "version": "2.11.20",
-      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.20.tgz",
-      "integrity": "sha512-H0ulySigv6icDJ1F7SjtdCD6PrhTpdYCmP0CactWy1+ekh0AFd0o1Wn5T8b+hnTmdBx19u9yhL6wvCylXMY7zw==",
+      "version": "2.11.24",
+      "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.24.tgz",
+      "integrity": "sha512-hYrgxie335U08WqICoGqKRzV1HFXv6zdxwJE4ekCb80CM9a0SVVsN4QPwT67RraRo+9h8IATk6uxHJw7QSkdOg==",
       "dev": true,
       "license": "Apache-2.0",
       "bin": {
@@ -1269,9 +1269,9 @@
       }
     },
     "node_modules/browserslist": {
-      "version": "4.28.8",
-      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.8.tgz",
-      "integrity": "sha512-V2NpofLblG64mfOtSgDhOJESZEGogzDMBv/q+W6oc4LXWP/q75eOXoOaaOu1EOadB9U4Bwx/e0yzbvwKH8zalA==",
+      "version": "4.29.0",
+      "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.0.tgz",
+      "integrity": "sha512-3GSvyjvDI4Dur1Meg2BekJquu5uF+9R9a1+5M1Mde192eZoXbeXjzgOsgqPS2V8D5wrrip0gR5Hf/GhWQ9ZzaA==",
       "dev": true,
       "funding": [
         {
@@ -1289,11 +1289,11 @@
       ],
       "license": "MIT",
       "dependencies": {
-        "baseline-browser-mapping": "^2.11.12",
-        "caniuse-lite": "^1.0.30001809",
-        "electron-to-chromium": "^1.5.402",
-        "node-releases": "^2.0.53",
-        "update-browserslist-db": "^1.3.0"
+        "baseline-browser-mapping": "^2.11.23",
+        "caniuse-lite": "^1.0.30001810",
+        "electron-to-chromium": "^1.5.427",
+        "node-releases": "^2.0.55",
+        "update-browserslist-db": "^1.3.3"
       },
       "bin": {
         "browserslist": "cli.js"
@@ -1408,9 +1408,9 @@
       }
     },
     "node_modules/electron-to-chromium": {
-      "version": "1.5.420",
-      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.420.tgz",
-      "integrity": "sha512-2yD6XreGusOfNV+dUcvipJEXc3n/n7fgr7996aszTG+YY5E4mqM4tOq/3uhP129cazL9YHbVWSpc79ePotWtPA==",
+      "version": "1.5.430",
+      "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.430.tgz",
+      "integrity": "sha512-e1QEj72Y4zd8RlNZVmoTg+iCOSVwpk05IOiiQwdrkwCSVlZfPthevErhE+nckGd2YbsXfp1SkisznhGVIXP2NQ==",
       "dev": true,
       "license": "ISC"
     },
@@ -1507,9 +1507,9 @@
       }
     },
     "node_modules/hono": {
-      "version": "4.13.7",
-      "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
-      "integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
+      "version": "4.13.8",
+      "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.8.tgz",
+      "integrity": "sha512-/Gng7NfoykZl2pjukW5Z6+8Yxm3BPRf86GTbQnt0SbySkvax4fyL4H3HhY1cCpBGmiW9XDRFzRV+CXK2W8QudQ==",
       "license": "MIT",
       "engines": {
         "node": ">=16.9.0"
@@ -1625,9 +1625,9 @@
       "license": "MIT"
     },
     "node_modules/node-releases": {
-      "version": "2.0.54",
-      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.54.tgz",
-      "integrity": "sha512-YHs7BmmcsdAI5Ozuf8JZo6PT0mv2GIWC9vMfvUC3dp65M8hn7Ux8CPL+2oBI7juNuj9d0ndhTcznq2ODBps9cQ==",
+      "version": "2.0.56",
+      "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.56.tgz",
+      "integrity": "sha512-x0InOIyzgdk+eyaWaRJFH5snEtiImgBgblZ2CyPrLmqqcuMQkEvcDPHbzqbD8eDsSeJbVOjn+crzyzHaM4D+/A==",
       "dev": true,
       "license": "MIT",
       "engines": {
@@ -1737,9 +1737,9 @@
       }
     },
     "node_modules/react": {
-      "version": "19.2.8",
-      "resolved": "https://registry.npmjs.org/react/-/react-19.2.8.tgz",
-      "integrity": "sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==",
+      "version": "19.3.0",
+      "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz",
+      "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==",
       "license": "MIT",
       "peer": true,
       "engines": {
@@ -1815,9 +1815,9 @@
       "license": "MIT"
     },
     "node_modules/update-browserslist-db": {
-      "version": "1.3.2",
-      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.2.tgz",
-      "integrity": "sha512-UQ+MSxlhRm1bzjhU+DcuXfjFO1FzNtqhK5+9Yvlp90ItDLk5vT932A0rFu619nf7RVS+Y/VeaUW1jaRDqZ8VJw==",
+      "version": "1.3.3",
+      "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz",
+      "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==",
       "dev": true,
       "funding": [
         {
diff --git a/package.json b/package.json
index f99ff4f..8382e51 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "dough-git",
-  "version": "0.1.0",
+  "version": "1.0.0",
   "description": "A minimal self-hosted git mirror: HTTP clone/pull/push + cgit-style viewer, gated by PocketID (OIDC). Styled with Vanilla Extract.",
   "type": "module",
   "private": true,
diff --git a/src/mirror.ts b/src/mirror.ts
index 5958979..afb33d7 100644
--- a/src/mirror.ts
+++ b/src/mirror.ts
@@ -258,6 +258,7 @@ export async function checkMirror(
   try {
     const remoteResult = await lsRemote(link.url);
     if (!remoteResult.ok) {
+      logIssue(ref, link, remoteResult.kind, remoteResult.message);
       if (remoteResult.kind === "denied" || remoteResult.kind === "missing") {
         recordSuccess(ref, link.kind, {
           state: remoteResult.kind,
@@ -282,26 +283,81 @@ export async function checkMirror(
     const localHead = head ? (local.get(head) ?? null) : null;
     const remoteHead = head ? (remote.get(head) ?? null) : null;
     const headVerdict = await ancestryVerdict(ref, localHead, remoteHead);
+    const state = rollUp(cmp, headVerdict);
+
+    for (const reason of mismatchReasons(cmp, local, remote)) {
+      logIssue(ref, link, state, reason);
+    }
 
     recordSuccess(ref, link.kind, {
-      state: rollUp(cmp, headVerdict),
+      state,
       localSha: localHead,
       remoteSha: remoteHead,
-      detail: `${cmp.matched}/${cmp.total} refs`,
+      detail: describeMismatch(cmp),
     });
     return true;
   } catch (err) {
-    recordFailure(
-      ref,
-      link.kind,
-      err instanceof Error ? err.message : "check failed",
-    );
+    const message = err instanceof Error ? err.message : "check failed";
+    logIssue(ref, link, "error", message);
+    recordFailure(ref, link.kind, message);
     return true;
   } finally {
     inFlight.delete(k);
   }
 }
 
+const ISSUE_LABELS: Record<string, string> = {
+  ahead: "mirror behind",
+  behind: "local behind",
+  diverged: "diverged",
+  out_of_sync: "out of sync",
+  denied: "private or missing",
+  missing: "repository missing",
+  error: "check failed",
+};
+
+function logIssue(
+  ref: RepoRef,
+  link: MirrorLink,
+  state: string,
+  reason: string,
+): void {
+  const label = ISSUE_LABELS[state] ?? state;
+  console.warn(`[mirror] ${refSlug(ref)} -> ${link.kind} ${label}: ${reason} (${link.url})`);
+}
+
+export function mismatchReasons(
+  cmp: Comparison,
+  local: Map<string, string>,
+  remote: Map<string, string>,
+): string[] {
+  const sha = (s: string | undefined) => (s ?? "?").slice(0, 7);
+  return [
+    ...cmp.differing.map(
+      (n) => `${shortRef(n)} differs (local ${sha(local.get(n))}, mirror ${sha(remote.get(n))})`,
+    ),
+    ...cmp.missingRemote.map((n) => `${shortRef(n)} not on mirror (local ${sha(local.get(n))})`),
+    ...cmp.missingLocal.map((n) => `${shortRef(n)} only on mirror (${sha(remote.get(n))})`),
+  ];
+}
+
+function shortRef(name: string): string {
+  return name.replace(/^refs\/heads\//, "").replace(/^refs\/tags\//, "tag ");
+}
+
+export function describeMismatch(cmp: Comparison): string {
+  const base = `${cmp.matched}/${cmp.total} refs`;
+  const parts = [
+    ...cmp.differing.map((n) => `${shortRef(n)} differs`),
+    ...cmp.missingRemote.map((n) => `${shortRef(n)} not on mirror`),
+    ...cmp.missingLocal.map((n) => `${shortRef(n)} only on mirror`),
+  ];
+  if (parts.length === 0) return base;
+  const shown = parts.slice(0, 2).join(", ");
+  const more = parts.length > 2 ? ` +${parts.length - 2} more` : "";
+  return `${base} (${shown}${more})`;
+}
+
 async function defaultBranchRef(
   ref: RepoRef,
   local: Map<string, string>,
diff --git a/test/mirror.test.mjs b/test/mirror.test.mjs
index 4715d32..c8b443e 100644
--- a/test/mirror.test.mjs
+++ b/test/mirror.test.mjs
@@ -23,6 +23,8 @@ const {
   dropMirrorStatus,
   markStale,
   needsCheck,
+  describeMismatch,
+  mismatchReasons,
 } = await import("../src/mirror.ts");
 const { classifyRemoteError, lsRemote, createRepo, refDir, localMirrorRefs } =
   await import("../src/git.ts");
@@ -115,6 +117,23 @@ cmp = compareRefs(
 check("differences both ways -> out_of_sync", rollUp(cmp, "synced") === "out_of_sync");
 check("empty on both sides -> synced", rollUp(compareRefs(m({}), m({})), null) === "synced");
 
+console.log("\n-- describing mismatches --");
+const both = [
+  m({ "refs/heads/main": A, "refs/heads/dev": A, "refs/tags/v1": A }),
+  m({ "refs/heads/main": A, "refs/heads/dev": B, "refs/heads/old": B }),
+];
+cmp = compareRefs(...both);
+const reasons = mismatchReasons(cmp, ...both);
+check("names a differing branch with both shas", reasons.includes("dev differs (local 1111111, mirror 2222222)"));
+check("names a ref missing on the mirror", reasons.includes("tag v1 not on mirror (local 1111111)"));
+check("names a ref only on the mirror", reasons.includes("old only on mirror (2222222)"));
+check("one reason per mismatched ref", reasons.length === 3);
+check("detail names the first two", describeMismatch(cmp) === "1/4 refs (dev differs, tag v1 not on mirror +1 more)");
+check(
+  "detail stays bare when synced",
+  describeMismatch(compareRefs(m({ "refs/heads/main": A }), m({ "refs/heads/main": A }))) === "1/1 refs",
+);
+
 console.log("\n-- ancestry, against a real repository --");
 const ref = { owner: "alice", name: "anc" };
 await createRepo(ref.owner, ref.name);