mergeLeft

tcmts.cli.merge.mergeLeft · #7h7gv3bw · term · runs anywhere

What a merge left to settle on this branch: its conflicted names, and what stopped typechecking (not what needed fixing before it).

import { needsFixing } from "#codebase/tcmts/cli/codebase";
import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { isConflicted } from "#codebase/tcmts/core/types";
import type { DefKind } from "#codebase/tcmts/core/types";

export function mergeLeft(
  cb: Codebase,
  before: Iterable<string>,
): { conflicts: string[]; failed: { name: string; message: string }[] } {
  const kinds = new Map<string, DefKind[]>();
  for (const r of cb.store.names(undefined, true))
    kinds.set(r.path, [...(kinds.get(r.path) ?? []), r.kind]);
  const conflicts = [...kinds].filter(([, k]) => isConflicted(k)).map(([p]) => p);
  const was = new Set(before);
  const failed = needsFixing(cb)
    .filter((t) => !was.has(t.hash))
    .map((t) => ({ name: cb.store.pathsOf(t.hash)[0] ?? t.hash, message: t.message }));
  return { conflicts, failed };
}

uses

used by