abortMerge

tcmts.cli.merge.abortMerge · #uoaceins · term · runs on the server

uses tcmts.cli.style.dim, which uses node:util

Drop the merge not finished into this branch: the branch is where it was all along, and what the merge recorded of its conflicts goes.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import { pendingMerge } from "#codebase/tcmts/cli/merge";
import { bold, dim } from "#codebase/tcmts/cli/style";

export function abortMerge(cb: Codebase): number {
  const branch = cb.store.branch().name;
  const p = pendingMerge(cb, branch);
  if (!p) {
    console.log(dim(`${branch} isn't merging anything`));
    return 0;
  }
  for (const k of p.conflictKeys) cb.store.deleteSetting(k);
  cb.store.deleteSetting(`merging ${branch}`);
  console.log(
    `dropped the merge of ${bold(p.theirs)} into ${bold(branch)}: ${branch} is as it was`,
  );
  return 0;
}

uses

used by