reset

tcmts.cli.main.reset · #awog3c7s · term · runs on the server

uses tcmts.cli.main.causalArg, which uses tcmts.cli.main.releaseAt, which uses tcmts.cli.manifests.packagesIn, which uses tcmts.cli.config.configValue, which uses node:path

Bring back the names as of a history entry: a new entry on top, so history (pushed or not) is never rewritten.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { causalArg } from "#codebase/tcmts/cli/main";
import { dim } from "#codebase/tcmts/cli/style";
import { shortHash } from "#codebase/tcmts/core/hash";

export function reset(cb: Codebase, target: string) {
  const c = causalArg(cb, target);
  const { added, removed, texts } = cb.store.setBranchNames(
    cb.store.branch().name,
    cb.store.namespaceRows(cb.store.causal(c)!.namespace),
    `reset ${shortHash(c)}`,
  );
  cb.refreshShim();
  console.log(
    added || removed || texts
      ? `names as of ${shortHash(c)} ${dim(`(${added} added, ${removed} removed${texts ? `, ${texts} reading as they did` : ""})`)}`
      : dim(`already as of ${shortHash(c)}`),
  );
}

uses

used by