todoList

tcmts.cli.main.todoList · #xec33gbg · term · runs anywhere

What needs fixing on this branch (as merged, while a merge waits apart: run it in the command): conflicts, the dependents that stopped typechecking (worked out, #o3gf55m7), then code using a version nothing names (left behind by a change it couldn't follow, or a name removed with --force; one needing fixing is in broken).

import { needsFixing } from "#codebase/tcmts/cli/codebase";
import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { TodoList } from "#codebase/tcmts/cli/main";
import { conflictAt, pendingMerge } from "#codebase/tcmts/cli/merge";
import { isConflicted } from "#codebase/tcmts/core/types";
import type { DefKind } from "#codebase/tcmts/core/types";

export function todoList(cb: Codebase): TodoList {
  const merging = pendingMerge(cb);
  const counts = new Map<string, DefKind[]>();
  for (const r of cb.store.names(undefined, true))
    counts.set(r.path, [...(counts.get(r.path) ?? []), r.kind]);
  const conflicts = [...counts]
    .filter(([, kinds]) => isConflicted(kinds))
    .flatMap(([p]) => conflictAt(cb, p) ?? []);
  const broken = needsFixing(cb).map((t) => ({
    hash: t.hash,
    names: cb.store.pathsOf(t.hash),
    message: t.message,
  }));
  const toFix = new Set(broken.map((t) => t.hash));
  const unnamed = cb.store
    .unnamedUses()
    .filter((u) => !toFix.has(u.hash))
    .map((u) => ({ path: u.path, uses: u.uses, madeAs: u.madeAs }));
  return {
    branch: cb.store.branch().name,
    ...(merging ? { merging: merging.theirs } : {}),
    conflicts,
    broken,
    unnamed,
  };
}

uses

used by