@coderook/cli 0.50.0 → 0.50.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@
2
2
  "name": "coderook",
3
3
  "displayName": "CodeRook",
4
4
  "description": "Save, browse and restore whole-snapshot versions of a project on CodeRook, with cbx or plain git, from Claude Code.",
5
- "version": "0.50.0",
5
+ "version": "0.50.1",
6
6
  "author": {
7
7
  "name": "ACCA Gaming Productions",
8
8
  "url": "https://coderook.com"
package/README.md CHANGED
@@ -420,7 +420,9 @@ Or start from the project instead: `git clone` it and carry on in the clone.
420
420
 
421
421
  **Pushing.** Each new commit becomes a version on the line its branch names,
422
422
  with its message kept, and its commit id unchanged. A branch pushed for the
423
- first time becomes a line. A push is refused with "fetch first" when the line
423
+ first time becomes a line. A merge arrives as a merge, with both parents: a
424
+ merged branch CodeRook never had goes onto a line of its own, named from the
425
+ merge (`merged/feature-x`). A push is refused with "fetch first" when the line
424
426
  has moved on since you pulled, as any git host refuses it.
425
427
 
426
428
  **What it does not do:**
@@ -128,83 +128,17 @@ async function readIssues(forge, token) {
128
128
  .filter((one) => one.title)
129
129
  .reverse();
130
130
  }
131
- function run(command, args, cwd, extra = {}) {
131
+ function run(command, args, cwd) {
132
132
  const result = (0, node_child_process_1.spawnSync)(command, args, {
133
133
  cwd,
134
134
  encoding: "utf8",
135
135
  maxBuffer: 1024 * 1024 * 64,
136
- ...(extra.input !== undefined ? { input: extra.input } : {}),
137
- ...(extra.env ? { env: extra.env } : {}),
138
136
  });
139
137
  return {
140
138
  ok: result.status === 0,
141
139
  out: `${result.stdout ?? ""}${result.stderr ?? ""}`,
142
140
  };
143
141
  }
144
- /**
145
- * Each branch as a straight line of its own first parents, for a history
146
- * with merges.
147
- *
148
- * CodeRook saves each pushed commit onto its line in turn, so the other side
149
- * of a merge has to be on CodeRook already (git_bridge.ts, service.ts); a
150
- * repository being moved has merged branches that no longer exist. The
151
- * commits up to the first merge are kept exactly, ids and all. From there
152
- * each commit is written again with the same tree, message, author and
153
- * dates and one parent, which is what the old coderook:// remote recorded
154
- * too: every merged tree exact, the fork in the history not. Returns the
155
- * old id of every commit rewritten, mapped to its new one.
156
- */
157
- function flatten(checkout, branches) {
158
- const map = new Map();
159
- for (const branch of branches) {
160
- const chain = run("git", ["rev-list", "--first-parent", "--reverse", `refs/heads/${branch}`], checkout).out.split("\n").filter(Boolean);
161
- let previous = null;
162
- for (const sha of chain) {
163
- const known = map.get(sha);
164
- if (known) {
165
- previous = known;
166
- continue;
167
- }
168
- const raw = run("git", ["cat-file", "commit", sha], checkout).out;
169
- const split = raw.indexOf("\n\n");
170
- const head = raw.slice(0, split < 0 ? raw.length : split);
171
- const message = split < 0 ? "" : raw.slice(split + 2);
172
- const parents = [...head.matchAll(/^parent ([0-9a-f]{40})$/gm)].map((m) => m[1]);
173
- const first = parents[0] ?? null;
174
- if (parents.length <= 1 && (first === null ? previous === null : map.get(first) === first && previous === first)) {
175
- map.set(sha, sha);
176
- previous = sha;
177
- continue;
178
- }
179
- const tree = /^tree ([0-9a-f]{40})$/m.exec(head)[1];
180
- const person = (role) => {
181
- const line = new RegExp(`^${role} (.*) <(.*)> (\\d+ [+-]\\d{4})$`, "m").exec(head);
182
- return line ? { name: line[1], email: line[2], date: line[3] } : null;
183
- };
184
- const author = person("author");
185
- const committer = person("committer");
186
- const made = run("git", ["commit-tree", tree, ...(previous ? ["-p", previous] : [])], checkout, {
187
- input: message,
188
- env: {
189
- ...node_process_1.default.env,
190
- ...(author ? { GIT_AUTHOR_NAME: author.name, GIT_AUTHOR_EMAIL: author.email, GIT_AUTHOR_DATE: author.date } : {}),
191
- ...(committer ? { GIT_COMMITTER_NAME: committer.name, GIT_COMMITTER_EMAIL: committer.email, GIT_COMMITTER_DATE: committer.date } : {}),
192
- },
193
- });
194
- const fresh = made.out.trim().split("\n").pop().trim();
195
- if (!made.ok || !/^[0-9a-f]{40}$/.test(fresh))
196
- throw new Error(`could not rewrite commit ${sha.slice(0, 7)}: ${made.out.trim()}`);
197
- map.set(sha, fresh);
198
- previous = fresh;
199
- }
200
- if (previous)
201
- run("git", ["update-ref", `refs/heads/${branch}`, previous], checkout);
202
- }
203
- for (const [from, to] of map)
204
- if (from === to)
205
- map.delete(from);
206
- return map;
207
- }
208
142
  async function commandTransfer(parsed) {
209
143
  const address = parsed.positional[0];
210
144
  if (!address) {
@@ -310,13 +244,8 @@ async function commandTransfer(parsed) {
310
244
  console.error((0, colour_js_1.red)("\nThe project was not created. Nothing else was changed."));
311
245
  return 1;
312
246
  }
313
- /* Merges flattened first: see flatten. */
247
+ /* Merges go across as merges: a merged branch that no longer exists becomes a line named merged/… (service.ts). */
314
248
  const merges = Number(run("git", ["rev-list", "--merges", "--count", "--all"], checkout).out.trim() || "0");
315
- let rewritten = new Map();
316
- if (merges) {
317
- console.log((0, colour_js_1.dim)(` ${merges} merge${merges === 1 ? "" : "s"}: each branch goes across as the line of commits it was built on.`));
318
- rewritten = flatten(checkout, remoteBranches);
319
- }
320
249
  console.log(`\n${(0, colour_js_1.dim)("Publishing the history…")}`);
321
250
  const results = await (0, git_bridge_js_1.bridgePush)(remoteBranches.map((branch) => ({ src: `refs/heads/${branch}`, dst: `refs/heads/${branch}`, force: false })), {
322
251
  url: `${(0, config_js_1.apiOrigin)()}/git/${encodeURIComponent(owner)}/${encodeURIComponent(project.slug ?? wanted)}.git`,
@@ -334,7 +263,7 @@ async function commandTransfer(parsed) {
334
263
  }
335
264
  report.push(`${commits} commits across ${remoteBranches.length} branch(es)`);
336
265
  if (merges)
337
- report.push(`${merges} merge(s) flattened: every merged tree is exact, and ${rewritten.size} commit(s) from the first merge on have new ids`);
266
+ report.push(`${merges} merge(s), kept as merges; branches merged and since deleted are lines named merged/…`);
338
267
  if (tags.length) {
339
268
  /* A tag names the version its commit became: a release, with an annotated tag's message as its notes. */
340
269
  const byCommit = new Map();
@@ -345,8 +274,7 @@ async function commandTransfer(parsed) {
345
274
  }
346
275
  let named = 0;
347
276
  for (const tag of tags) {
348
- const tagged = run("git", ["rev-parse", "--verify", `refs/tags/${tag}^{commit}`], checkout).out.trim();
349
- const commit = rewritten.get(tagged) ?? tagged;
277
+ const commit = run("git", ["rev-parse", "--verify", `refs/tags/${tag}^{commit}`], checkout).out.trim();
350
278
  const versionId = byCommit.get(commit);
351
279
  if (!versionId)
352
280
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coderook/cli",
3
- "version": "0.50.0",
3
+ "version": "0.50.1",
4
4
  "description": "The command line for CodeRook (coderook.com): version control and project hosting for projects of any size. Every save is a compressed snapshot, private or public, never used to train AI.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://coderook.com",
@@ -141,7 +141,8 @@ old `coderook://` remote is retired: a fetch through it prints the
141
141
  `git remote set-url` command that moves it to the plain address.
142
142
 
143
143
  Git's limits here: no force pushes or branch deletions (saves are permanent), a
144
- merge commit arrives as one save holding the merged tree, and a commit holding
144
+ merge arrives as a merge (a merged branch CodeRook never had becomes a line
145
+ named `merged/<branch>`), and a commit holding
145
146
  a credential is refused — take the key out of history rather than looking for
146
147
  a way round.
147
148