testReleasesTravelAndNeverChange

tcmts.cli.test.e2e.releases.testReleasesTravelAndNeverChange · #cmm5mfyr · term

releases travel with push and pull, list the contributions that touched them, and never change

import { codebase } from "#codebase/tcmts/cli/test/e2e/releases";
import assert from "node:assert/strict";

export const testReleasesTravelAndNeverChange = () => {
  const server = codebase("server");
  server.save(`// tcm: namespace lib\nexport const manifest = { name: "lib" };\nexport const one = 1;\n`, "add");
  server.save(`// tcm: namespace tools\nexport const manifest = { name: "tools" };\nexport const t = 1;\n`, "add");
  const me = codebase("me");
  me.tcm("remote", "add", "origin", server.dir);
  me.tcm("pull");
  me.tcm("release", "lib@1.0.0");
  me.tcm("release", "tools@1.0.0");
  assert.match(me.tcm("push"), /released lib@1\.0\.0, tools@1\.0\.0 on origin|released tools@1\.0\.0, lib@1\.0\.0 on origin/);
  assert.match(server.tcm("releases"), /lib {2}lib\n {2}1\.0\.0 /);

  // a contribution merged on the server shows in the next release of the package it touched, not the other
  me.tcm("branch", "two");
  me.tcm("switch", "two");
  me.save(`// tcm: namespace lib\n/** Two. */\nexport const two = 2;\n`, "add");
  me.tcm("contribute", "--title", "Add two");
  me.tcm("contribution", "merge", "1");
  me.tcm("switch", "main");
  me.tcm("pull");
  assert.match(me.tcm("release", "lib"), /### Added\n\n- `lib\.two` `2`: Two\.\n\n### Contributions\n\n- #1 Add two \(ada\)/);
  me.save(`// tcm: namespace tools\nexport const t = 2;\n`);
  assert.doesNotMatch(me.tcm("release", "tools"), /Contributions/);
  me.tcm("push");

  // a codebase that pulls gets the releases, with the history they name
  const other = codebase("other");
  other.tcm("remote", "add", "origin", server.dir);
  assert.match(other.tcm("pull"), /received release\(s\) .*lib@1\.1\.0/);
  assert.equal(other.tcm("changelog", "lib"), me.tcm("changelog", "lib"));
  assert.match(other.tcm("diff", "lib@1.0.0", "lib@1.1.0"), /\+ lib\.two/);

  // the same version made differently elsewhere is refused, not overwritten
  const rogue = codebase("rogue");
  rogue.save(`// tcm: namespace lib\nexport const manifest = { name: "lib" };\nexport const x = 1;\n`, "add");
  rogue.tcm("release", "1.1.0");
  rogue.tcm("remote", "add", "origin", server.dir);
  assert.match(rogue.run("pull").out, /has a different lib@1\.1\.0 .*a version names one release, for good/);
}

uses