branchChanges

tcmts.cli.changes.branchChanges · #ymuaiwaq · term · runs anywhere

What another branch has that this one doesn't, name by name: the changes from this branch to it.

import { namesChanged } from "#codebase/tcmts/cli/changes";
import type { NameChange, NamesFrom } from "#codebase/tcmts/cli/changes";
import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { stateOf } from "#codebase/tcmts/cli/diff";

export function branchChanges(
  cb: Codebase,
  branch: string,
  viewUri: (hash: string, names: NamesFrom) => string,
): NameChange[] {
  if (!cb.store.hasBranch(branch)) throw new Error(`no branch named '${branch}'`);
  return namesChanged(
    cb,
    stateOf(cb.store.names(undefined, true)),
    stateOf(cb.store.names(branch, true)),
    (h, side) => viewUri(h, side === "before" ? {} : { branch }),
  );
}

uses

used by