namesFrom
The names a history entry or branch gives definitions: a definition's first name there.
import type { NamesFrom } from "#codebase/tcmts/cli/changes"; import type { Codebase } from "#codebase/tcmts/cli/codebase"; export function namesFrom(cb: Codebase, from: NamesFrom): (hash: string) => string | undefined { const rows = from.at ? cb.store.namespaceRows(cb.store.causal(from.at)!.namespace) : cb.store.names(from.branch, true); const first = new Map<string, string>(); for (const r of [...rows].sort((a, b) => (a.path < b.path ? -1 : 1))) if (!first.has(r.hash)) first.set(r.hash, r.path); return (h) => first.get(h); }