printSettled
uses tcmts.cli.style.green, which uses node:util
What settling a merge (or a revert: what) did, after its diff: names merged as text, kept, still conflicted
(each definition labelled with its side), and what no longer typechecks.
import { keyPath } from "#codebase/tcmts/cli/diff"; import { conflictLine } from "#codebase/tcmts/cli/merge"; import type { Settled } from "#codebase/tcmts/cli/merge"; import { bold, dim, green, red, yellow } from "#codebase/tcmts/cli/style"; export function printSettled( s: Settled, labels: { ours: string; theirs: string }, what: string, ): void { if (s.textMerged.length) console.log(); for (const k of s.textMerged) console.log( `${green(" merged as text")} ${bold(k)} ${dim("(both sides edited it, apart: their edits are combined, and it typechecks)")}`, ); for (const k of s.keptForUse) console.log( `${yellow(" kept")} ${bold(k)} ${dim("(deleted on one side, but the other's code uses it)")}`, ); for (const c of s.conflicts) console.log( ` ${conflictLine({ key: c.key, path: keyPath(c.key), // (ours first, as `tcm todo` lists them) sides: [...c.sides] .sort((a, b) => Number(a.side !== "ours") - Number(b.side !== "ours")) .map((x) => (x.side ? { ...x, label: labels[x.side] } : { hash: x.hash })), })}`, ); if (s.failed.length) { const shown = s.failed.slice(0, 8).join(", ") + (s.failed.length > 8 ? `, and ${s.failed.length - 8} more` : ""); console.log( red( ` ${s.failed.length} definition(s) no longer typecheck after the ${what}: ${shown}; see \`tcm todo\``, ), ); if (s.conflicts.length) console.log( dim( ` (code reaching a conflicted definition through others both sides only re-derived uses this branch's; \`tcm resolve\` re-derives what used either against the one kept)`, ), ); } if (!s.conflicts.length && !s.failed.length) console.log(green(`\n ${what === "merge" ? "merged" : "reverted"} cleanly`)); }
uses
- tcmts.cli.diff.keyPath
- tcmts.cli.merge.Settled
- tcmts.cli.merge.conflictLine
- tcmts.cli.style.bold
- tcmts.cli.style.dim
- tcmts.cli.style.green
- tcmts.cli.style.red
- tcmts.cli.style.yellow