Skip to content
38 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.

Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them1/**
2 * Each entry's last commit for the file list, waited on only so long. An
3 * answer not yet kept walks history, which can take seconds on a large or
4 * busy repository; the page goes out without it then, the column empty,
5 * while the walk finishes in the background (waitUntil) so the next view
6 * has it from the cache. The page's stream never waits on it past its own
7 * timeout.
8 */
9import { waitUntil } from "cloudflare:workers";
10
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)11import type { RepoPath, Viewer } from "@g1t/contracts";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them12
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)13import type { FileCommits } from "./commit-people";
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them14import { repos } from "./services.server";
15
16/** How long the page waits for the column. */
17const WAIT_MS = 3_000;
18
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)19export function lastCommitsFor(path: RepoPath, viewer: Viewer, ref: string | null, treePath: string): Promise<FileCommits | null> {
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them20 const walk = repos
21 .lastCommits(path, viewer, ref, treePath)
Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016)22 // The rows show a commit's subject and age, never who made it: their
23 // addresses stay on the server.
24 .then((found): FileCommits | null =>
25 found.ok
26 ? {
27 complete: found.value.complete,
28 entries: found.value.entries.map(({ name, commit }) => ({
29 name,
30 commit: { hash: commit.hash, message: commit.message, authoredAt: commit.authoredAt },
31 })),
32 }
33 : null,
34 )
Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them35 .catch(() => null);
36 waitUntil(walk);
37 return Promise.race([walk, new Promise<null>((resolve) => setTimeout(() => resolve(null), WAIT_MS))]);
38}

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