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 them | 1 | /** |
| 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 | |
| Merge last commits over the whole history: progress kept per ref and path, a push reads only its own commits | 6 | * has it from the cache. A history too long for one walk is read over |
| 7 | * several views: the repos service keeps each walk's progress and goes on | |
| 8 | * from it (services/repos/src/last_commits.rs). The page's stream never | |
| 9 | * waits on it past its own timeout. | |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 10 | */ |
| 11 | import { waitUntil } from "cloudflare:workers"; | |
| 12 | ||
| Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016) | 13 | import 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 them | 14 | |
| Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016) | 15 | import 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 them | 16 | import { repos } from "./services.server"; |
| 17 | ||
| 18 | /** How long the page waits for the column. */ | |
| 19 | const WAIT_MS = 3_000; | |
| 20 | ||
| Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016) | 21 | export 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 them | 22 | const walk = repos |
| 23 | .lastCommits(path, viewer, ref, treePath) | |
| Merge commit authors and hovercards: commits show their accounts, every name opens a card (repos 0016) | 24 | // The rows show a commit's subject and age, never who made it: their |
| 25 | // addresses stay on the server. | |
| 26 | .then((found): FileCommits | null => | |
| 27 | found.ok | |
| 28 | ? { | |
| 29 | complete: found.value.complete, | |
| 30 | entries: found.value.entries.map(({ name, commit }) => ({ | |
| 31 | name, | |
| 32 | commit: { hash: commit.hash, message: commit.message, authoredAt: commit.authoredAt }, | |
| 33 | })), | |
| 34 | } | |
| 35 | : null, | |
| 36 | ) | |
| Last commits read trees two dozen commits at a time, and the file list waits at most 3 s for them | 37 | .catch(() => null); |
| 38 | waitUntil(walk); | |
| 39 | return Promise.race([walk, new Promise<null>((resolve) => setTimeout(() => resolve(null), WAIT_MS))]); | |
| 40 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.