Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 4 | import type { BranchDrifts, Commit } from "@g1t/contracts"; |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 5 | |
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 6 | import { activeBranches, branchesToRead } from "./branches.ts"; |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 7 | |
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 8 | const commit = (hash: string, at: string, message = `${hash}\n\nbody`): Commit => ({ |
| 9 | hash, | |
| 10 | treeHash: `t${hash}`, | |
| 11 | message, | |
| 12 | author: { name: "Ada", email: "ada@example.com" }, | |
| 13 | parents: [], | |
| 14 | authoredAt: at, | |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 15 | }); |
| 16 | ||
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 17 | const branches = [ |
| 18 | { name: "main", hash: "m3" }, | |
| 19 | { name: "old", hash: "o1" }, | |
| 20 | { name: "fix", hash: "f2" }, | |
| 21 | { name: "idea", hash: "i1" }, | |
| 22 | ]; | |
| 23 | const pulls = [{ branch: "fix", number: 7, title: "Fix it", checkStatus: "passed" as const, status: "open" as const }]; | |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 24 | |
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 25 | test("branches with an open pull request are read first, the default branch never", () => { |
| 26 | const read = branchesToRead({ defaultBranch: "main", branches, pulls }, 2); | |
| 27 | assert.deepEqual(read.reading.map((b) => b.name), ["fix", "old"]); | |
| 28 | assert.equal(read.total, 3); | |
| 29 | assert.equal(read.mainHead, "m3"); | |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 30 | }); |
| 31 | ||
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 32 | test("no default branch head, nothing to measure against", () => { |
| 33 | assert.equal(branchesToRead({ defaultBranch: "trunk", branches, pulls: [] }, 10).mainHead, null); | |
| Usage, Billing settings and prepaid AI credit; fixes from the UX audit | 34 | }); |
| 35 | ||
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 36 | test("each branch gets its measured commit and drift, newest first, by head hash", () => { |
| 37 | const measured: BranchDrifts = { | |
| 38 | base: commit("m3", "2026-10-08T00:00:00Z"), | |
| 39 | branches: [ | |
| 40 | { head: "f2", commit: commit("f2", "2026-10-07T00:00:00Z"), drift: { ahead: 2, behind: 1 } }, | |
| 41 | { head: "o1", commit: commit("o1", "2026-01-01T00:00:00Z"), drift: null }, | |
| 42 | { head: "i1", commit: commit("i1", "2026-10-08T00:00:00Z", "one line"), drift: { ahead: 1, behind: 0 } }, | |
| 43 | ], | |
| 44 | }; | |
| 45 | const { reading } = branchesToRead({ defaultBranch: "main", branches, pulls }, 10); | |
| 46 | const shown = activeBranches(reading, measured, { pulls, previews: [{ number: 7, url: "https://fix.g1t.page" }] }); | |
| 47 | assert.deepEqual(shown.map((b) => b.name), ["idea", "fix", "old"]); | |
| 48 | assert.deepEqual(shown[1], { | |
| 49 | name: "fix", | |
| 50 | commit: { hash: "f2", message: "f2", author: "Ada", at: "2026-10-07T00:00:00Z" }, | |
| 51 | drift: { ahead: 2, behind: 1 }, | |
| 52 | pull: { number: 7, title: "Fix it", checkStatus: "passed", draft: false }, | |
| 53 | preview: "https://fix.g1t.page", | |
| 54 | }); | |
| 55 | assert.equal(shown[2]?.drift, null); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 56 | }); |
| 57 | ||
| Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 25 | 58 | test("when repos could not answer, the branches still show, without commits or counts", () => { |
| 59 | const { reading } = branchesToRead({ defaultBranch: "main", branches, pulls: [] }, 10); | |
| 60 | const shown = activeBranches(reading, null, { pulls: [], previews: [] }); | |
| 61 | assert.equal(shown.length, 3); | |
| 62 | assert.ok(shown.every((b) => b.commit == null && b.drift == null && b.pull == null)); | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 63 | }); |
This file's history is long; its oldest lines are credited to the oldest commit read.