fixCount

tcmts.studio.fixCount · #au4kdk2g · term · runs on the server

uses tcmts.share.servedCodebase, which uses process

How many things need fixing on the branch cb reads, for the studio's tabs: conflicts and what stopped typechecking (while a merge waits apart, as fixesOf last said, or at least the merge).

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { todoList } from "#codebase/tcmts/cli/main";
import { servedCodebase } from "#codebase/tcmts/share";
import { mergeViews, mergeWaiting } from "#codebase/tcmts/studio";

export function fixCount(cb: Codebase): number {
  const waiting = cb === servedCodebase().cb ? mergeWaiting(cb) : undefined;
  if (waiting) {
    const known = mergeViews.get(`${cb.store.branch().name} ${waiting}`);
    return known ? known.conflicts.length + known.broken.length || 1 : 1;
  }
  const list = todoList(cb);
  return list.conflicts.length + list.broken.length;
}

uses

used by