fetchHistory
Fetch what this codebase lacks of the remote's history up to head; returns definitions received.
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { chunks, fetchNamespaces, oldestFirst } from "#codebase/tcmts/cli/sync"; import type { Remote } from "#codebase/tcmts/cli/sync"; import type { Causal } from "#codebase/tcmts/store"; export async function fetchHistory(cb: Codebase, remote: Remote, head: string): Promise<number> { const lacking = cb.store.missingCausals(await remote.ancestors(head)); if (!lacking.length) return 0; const causals: Causal[] = []; for (const c of chunks(lacking)) causals.push(...(await remote.getCausals(c))); // (the namespaces they name, and their code, before the history naming them) const stored = await fetchNamespaces( cb, remote, causals.map((c) => c.namespace), ); cb.store.putCausals(oldestFirst(causals)); return stored; }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.sync.Remote
- tcmts.cli.sync.chunks
- tcmts.cli.sync.fetchNamespaces
- tcmts.cli.sync.oldestFirst
- tcmts.store.Causal