testMessagesSayWhatEntriesAreFor
A message says what an entry is for: given with -m, it's the entry's title in history, in no hash, changed with
tcm describe, and carried by pull and push; where an entry is kept already, its message stays as it is there.
import { tempDir } from "#codebase/tcmts/cli/test/e2e/harness"; import { codebase } from "#codebase/tcmts/cli/test/e2e/history"; import assert from "node:assert/strict"; export const testMessagesSayWhatEntriesAreFor = () => { const root = tempDir("history"); const a = codebase(root, "a"); const b = codebase(root, "b"); const c = codebase(root, "c"); a.tcm("init"); a.write(`export const v = 1;\n`); a.tcm("add", "-m", "v: the first value"); a.write(`export const v = 2;\n`); a.tcm("update", "--message", "v: two, not one\n\nOne was off by one.\n"); assert.match( a.tcm("history"), /^#\w{8} +0 .* v: two, not one\n {4}One was off by one\.\n {4}update v\n {4}v +#\w{8} → #\w{8}\n#\w{8} +1 .* v: the first value\n {4}add v\n {4}v +\+ #\w{8}/, ); // without one, an entry is named by what it changed, as ever a.write(`export const w = 3;\n`); a.tcm("add"); assert.match(a.tcm("history", "1"), /^#\w{8} +0 .* add w\n {4}w +\+ #\w{8}\n?$/); // the same change from the same point is the same entry, said for or not: no hash has the message c.tcm("init"); c.write(`export const v = 1;\n`); c.tcm("add"); assert.equal(c.entries()[0], a.entries()[2]); // describe: shown, given, taken away, and history the same const before = a.entries(); assert.equal(a.tcm("describe", "2").trim(), "v: the first value"); assert.match(a.tcm("describe", "-m", "w: a third"), /add w\): w: a third/); assert.match(a.tcm("history", "1"), /^#\w{8} +0 .* w: a third\n {4}add w\n/); assert.match(a.tcm("describe", `#${before[2]}`, "-m", ""), /has no message now/); assert.match(a.tcm("history"), /#\w{8} +2 .* add v\n/); assert.deepEqual(a.entries(), before); // pull and push carry messages b.tcm("init"); b.tcm("remote", "add", "origin", a.dir); b.tcm("pull"); assert.deepEqual(b.entries(), a.entries()); assert.match(b.tcm("history"), /w: a third\n[\s\S]*v: two, not one\n {4}One was off by one\./); b.write(`export const x = 4;\n`); b.tcm("add", "-m", "x: a fourth"); b.tcm("push"); assert.match(a.tcm("history", "1"), /^#\w{8} +0 .* x: a fourth\n {4}add x\n/); // a message changed after the entry went is changed here, not where it went b.tcm("describe", "0", "-m", "x: the fourth"); b.tcm("push"); assert.match(a.tcm("history", "1"), /x: a fourth/); assert.match(b.tcm("history", "1"), /x: the fourth/); }