branchConflicts

tcmts.cli.merge.branchConflicts · #gqucoxyy · term · runs anywhere

The conflicts kept for a branch (ConflictRecord), by name as merges key it: what sync carries with the branch (beside its history, so no hash changes), so a conflict pushed or pulled is labelled as the merge that made it labelled it.

import type { Codebase } from "#codebase/tcmts/cli/codebase";
import type { ConflictRecord } from "#codebase/tcmts/cli/merge";

export function branchConflicts(cb: Codebase, branch: string): Record<string, ConflictRecord> {
  const prefix = `conflict ${branch} `;
  const out: Record<string, ConflictRecord> = {};
  for (const [k, v] of cb.store.settings(prefix)) {
    if (!k.startsWith(prefix)) continue;
    try {
      out[k.slice(prefix.length)] = JSON.parse(v) as ConflictRecord;
    } catch {
      // (not one: left out)
    }
  }
  return out;
}

uses

used by