import { useQuery } from '@tanstack/react-query'; import { Link } from '#/components/atoms/link.jsx'; import { checkLook, loadChecks, summarize, summaryWords, } from '#/lib/checks.js'; import { cn } from '#/lib/utils.js'; /** * How one commit's checks ended, as a fact in its header: the mark, the * words, and the way to the run that says why. * * A commit page is about the diff. What the runner did belongs to the run's * own page, which holds the log, so this says the one thing a reader wants * on the way past and links to the rest. * * Nothing is drawn when the repository names no runner, or the runner has * not reported on this commit. */ export function CommitCheckLine({ repo, sha, className, space }) { const { data } = useQuery({ queryKey: ['checks', repo, space ?? ''], queryFn: () => loadChecks(repo, space), }); const latest = data?.bySha.get(sha) ?? []; const summary = summarize(latest); if (!summary) return null; const look = checkLook(summary.status); // One workflow has a page of its own. Several have no one page but the // listing, which gathers every run under the commit it ran against. const only = latest.length === 1 && latest[0].rkey; const at = `/${encodeURIComponent(repo)}/checks`; return ( {summaryWords(summary, latest)} ); }