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.
| Merge checks: statuses and check runs on every commit | 1 | /** |
| 2 | * The checks on a page's commits, read in one call for all of them (the | |
| 3 | * work service's `commit_checks`): statuses, check runs reported through | |
| 4 | * the API, and g1t Actions jobs. Loaders return the promise without | |
| 5 | * waiting, so the page goes out at once and each commit's badge streams in | |
| 6 | * (components/commit-checks.tsx). | |
| 7 | */ | |
| 8 | import type { CommitChecks, RepoPath, Viewer } from "@g1t/contracts"; | |
| 9 | ||
| 10 | import { work } from "./services.server"; | |
| 11 | ||
| 12 | /** A page's commits' checks, by full SHA. A commit nothing reported on is absent. */ | |
| 13 | export type ChecksBySha = Record<string, CommitChecks>; | |
| 14 | ||
| 15 | /** The most commits one call reads. */ | |
| 16 | const MAX_COMMITS = 100; | |
| 17 | ||
| 18 | /** Every check on each of `shas`; null when they could not be read. */ | |
| 19 | export function commitChecksFor(path: RepoPath, viewer: Viewer, shas: (string | null | undefined)[]): Promise<ChecksBySha | null> { | |
| 20 | const unique = [...new Set(shas.filter((sha): sha is string => Boolean(sha)))].slice(0, MAX_COMMITS); | |
| 21 | if (unique.length === 0) return Promise.resolve({}); | |
| 22 | return work | |
| 23 | .commitChecks(path, viewer, unique) | |
| 24 | .then((found) => (found.ok ? found.value : null)) | |
| 25 | .catch(() => null); | |
| 26 | } |
This file's history is long; its oldest lines are credited to the oldest commit read.