- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/test/labels.test.ts --json
- JSON
- /christopher/abso-core/blame/worker/project/test/labels.test.ts?format=json
83 linesFirst import 99% · rename 1%Last change rename in version 100,
83 lines from 2 changes in 2 versions.
2// follow the newest version with a given label, which is the hook project
3// gates need.
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { MemoryStore, Project, ProjectError } from "../project.ts";
9function setup() {
10 const store = new MemoryStore();
11 const project = new Project(store);
12 project.init({ "a.txt": "v0\n" }, 0);
13 return { project, store };
14}
16/** Publish versions 1..n, each changing a.txt to "v<n>". */
17function publishVersions(project: Project, n: number): void {
18 for (let v = 1; v <= n; v++) {
19 project.sync("dev");
20 project.record("dev", { "a.txt": `v${v}\n` }, v);
21 project.publish("dev", `Version ${v}`, v);
22 }
23}
25test("labels mark versions, show in log, and come off", () => {
26 const { project } = setup();
27 publishVersions(project, 3);
28 assert.deepEqual(project.label("ci", "passed-ci", 1, 10), { name: "passed-ci", version: 1, versions: [1] });
29 assert.deepEqual(project.label("ci", "passed-ci", undefined, 11), {
30 name: "passed-ci",
31 version: 3,
32 versions: [3, 1],
33 });
34 project.label("ci", "release", 1, 12);
35 assert.deepEqual(project.labels(), { labels: { "passed-ci": [3, 1], release: [1] } });
36 assert.deepEqual(project.log().versions.find((v) => v.version === 1)!.labels, ["passed-ci", "release"]);
37 // Labelling again does nothing; removing takes it off.
38 const before = project.log();
39 project.label("ci", "passed-ci", 3, 13);
40 assert.deepEqual(project.log(), before);
41 project.label("ci", "passed-ci", 3, 14, { remove: true });
42 assert.deepEqual(project.labels().labels["passed-ci"], [1]);
43});
45test("a folder follows the newest version with a label, not the newest version", () => {
46 const { project } = setup();
47 publishVersions(project, 2);
48 project.label("ci", "passed-ci", 1, 10);
49 const s = project.sync("gate", { label: "passed-ci" });
50 assert.equal(s.version, 1);
51 assert.deepEqual(s.files, { "a.txt": "v1\n" });
52 // CI passes version 2: the follower moves up; a plain sync goes to the newest.
53 project.label("ci", "passed-ci", 2, 11);
54 assert.deepEqual(project.sync("gate", { label: "passed-ci" }).files, { "a.txt": "v2\n" });
55 publishVersions(project, 3);
56 assert.deepEqual(project.sync("gate", { label: "passed-ci" }), { version: 2, files: {}, collisions: [] });
57 assert.equal(project.sync("gate").version, 5);
58});
60test("following a label back is refused when it would strand the agent's own work", () => {
61 const { project } = setup();
62 publishVersions(project, 2);
63 project.label("ci", "passed-ci", 1, 10);
64 project.sync("dev");
65 project.edit("dev", { file: "a.txt", old: "v2", new: "v2 and more" }, 11);
66 assert.throws(
67 () => project.sync("dev", { label: "passed-ci" }),
68 (e: unknown) => e instanceof ProjectError && e.code === "conflict" && /version 1 doesn't have yet/.test(e.message),
69 );
70 assert.throws(() => project.sync("dev", { label: "nothing" }), /no version of shared has the label/);
71 assert.throws(() => project.label("ci", "bad label", 1, 12), /bad label/);
72 assert.throws(() => project.label("ci", "ok", 99, 12), /no version 99/);
73});
rename100abso publish is now abso push, abso sync is now abso pull (abso 427)
Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing.
push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch.
Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare75test("a log with labels and label-following pulls loads back the same", () => {
77 publishVersions(project, 2);
78 project.label("ci", "passed-ci", 1, 10);
79 project.sync("gate", { label: "passed-ci" });
80 const again = Project.load(store.entries, new MemoryStore());
81 assert.deepEqual(again.labels(), project.labels());
82 assert.deepEqual(again.status(), project.status());
83});