Skip to content
47 linesCodeBlameRaw

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.

Branches and Tags pages, each file's last commit, and the branch menu on files1/**
2 * A repository's branches as its pages show them: each one's head commit,
3 * how far it has moved from the default branch, the pull request open on
4 * it with its checks, and its preview. The overview shows the newest few;
5 * the Branches page shows them all.
6 */
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)7import type { Branch, BranchDrifts, Commit, Pull, RepoPath, Viewer } from "@g1t/contracts";
Branches and Tags pages, each file's last commit, and the branch menu on files8
9import type { ActiveBranch } from "../components/branches";
Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 2510import { activeBranches, branchesToRead, summary } from "./branches";
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)11import { addressesToMatch, showCommit } from "./commit-people";
12import { emailOwners } from "./commit-people.server";
Branches and Tags pages, each file's last commit, and the branch menu on files13import { repos } from "./services.server";
14
15type Preview = { branch?: string | null; number?: number | null; url: string };
Usage, Billing settings and prepaid AI credit; fixes from the UX audit16
Branches and Tags pages, each file's last commit, and the branch menu on files17/**
18 * The branches other than the default, at most `read` of them read (those
Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 2519 * with an open pull request first), newest commit first, and the default
20 * branch's head commit with its first line.
21 *
22 * One call to repos (`branch_drift`, services/repos/src/drift.rs) measures
23 * every branch. It keeps each answer by the pair of head commits, so only
24 * branches that moved, or every branch once the default branch moved, cost
25 * a walk, and that walk reads the default branch's history once for all of
26 * them. Before 2026-10-08 this was a `log` call per branch per depth from
27 * here, up to twenty on an overview.
Branches and Tags pages, each file's last commit, and the branch menu on files28 */
29export async function readBranches(
30 path: RepoPath,
31 viewer: Viewer,
32 input: { defaultBranch: string; branches: Branch[]; pulls: Pull[]; previews: Preview[] },
33 read: number,
34): Promise<{ main: string; total: number; shown: ActiveBranch[]; head: ActiveBranch["commit"] }> {
Merge project overview: one branch_drift call, spliced histories, cached tags, 6 repos calls instead of 2535 const { reading, total, mainHead } = branchesToRead(input, read);
36 const measured: BranchDrifts | null = mainHead
37 ? await repos
38 .branchDrift(path, viewer, mainHead, reading.map((branch) => branch.hash).filter(Boolean))
39 .then((found) => (found.ok ? found.value : null))
40 .catch(() => null)
41 : null;
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)42 // Every head commit's people, in one identity call.
43 const heads = [measured?.base, ...(measured?.branches ?? []).map((one) => one.commit)].filter((commit): commit is Commit => commit != null);
44 const owners = await emailOwners(addressesToMatch(heads));
45 const people = (commit: Commit) => showCommit(commit, owners);
46 return { main: input.defaultBranch, total, shown: activeBranches(reading, measured, input, people), head: summary(measured?.base, people) };
Branches and Tags pages, each file's last commit, and the branch menu on files47}

This file's history is long; its oldest lines are credited to the oldest commit read.