@feigi/fleet-ctl 3.18.7 → 3.18.8
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.
package/package.json
CHANGED
|
@@ -71,15 +71,17 @@
|
|
|
71
71
|
// Without a ledger the record is judged all the same and the exit status is
|
|
72
72
|
// the whole verdict: no token is written, no row is read, and `token` in the
|
|
73
73
|
// stdout payload is null. That is the shape of a standalone `/review-and-fix`
|
|
74
|
-
// with no controller,
|
|
74
|
+
// with no controller, chosen by `--no-ledger` or by a ledger path that does
|
|
75
|
+
// not exist.
|
|
75
76
|
// A repository's `.fleet/ledger.md` outlives the fleet run that wrote it, so a
|
|
76
77
|
// standalone member in a worktree of such a repository would otherwise find
|
|
77
78
|
// the previous run's ledger, and a ledger that exists is never skipped: one
|
|
78
79
|
// holding no row for the member is a fault (exit 2), as is a ledger path that
|
|
79
80
|
// cannot be looked up (a parent that is a file, no permission, a symlink loop).
|
|
80
|
-
// Only a path that does not exist is "no ledger"
|
|
81
|
-
//
|
|
82
|
-
//
|
|
81
|
+
// Only a path that does not exist is "no ledger": the default path, or one
|
|
82
|
+
// `--ledger` names, which also prints a note on stderr that no token was
|
|
83
|
+
// written. `--no-ledger` names that state outright: no ledger is looked for,
|
|
84
|
+
// whatever the repository holds, and it contradicts `--ledger`.
|
|
83
85
|
|
|
84
86
|
import { readFileSync, existsSync, lstatSync } from "node:fs";
|
|
85
87
|
import { execFileSync } from "node:child_process";
|
|
@@ -410,8 +412,10 @@ function runLedger(ledgerFile, args, what) {
|
|
|
410
412
|
// where `ledger.mjs dispatch` wrote the member's row. The path is handed to
|
|
411
413
|
// `ledger.mjs` as `--file`, so the existence probe and the calls that follow
|
|
412
414
|
// answer for one file. Only ENOENT means "there is none": any other failure
|
|
413
|
-
// to look the path up is a fault, not a standalone run.
|
|
414
|
-
//
|
|
415
|
+
// to look the path up is a fault, not a standalone run. An absent path named
|
|
416
|
+
// by `--ledger` is announced on stderr; an absent default path is not.
|
|
417
|
+
// `lstat`, not `stat`, so a dangling symlink is a ledger that cannot be read
|
|
418
|
+
// rather than an absent one.
|
|
415
419
|
function ledgerInUse(explicit, repo) {
|
|
416
420
|
const file = explicit ?? join(
|
|
417
421
|
workspaceDirFromGitCommonDir(git(repo, ["rev-parse", "--git-common-dir"], "find the git common dir"), repo)
|
|
@@ -422,7 +426,10 @@ function ledgerInUse(explicit, repo) {
|
|
|
422
426
|
lstatSync(file);
|
|
423
427
|
return file;
|
|
424
428
|
} catch (e) {
|
|
425
|
-
if (e.code === "ENOENT")
|
|
429
|
+
if (e.code === "ENOENT") {
|
|
430
|
+
if (explicit !== null) console.error(`${NAME}: no ledger at ${file} (named by --ledger) — judged with no ledger, so no token was written; pass --no-ledger to choose that`);
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
426
433
|
die(`could not look for the ledger ${file}: ${e.message}`);
|
|
427
434
|
}
|
|
428
435
|
}
|
|
@@ -376,6 +376,7 @@ test("with no ledger the exit status is the verdict, and nothing is written to a
|
|
|
376
376
|
okVerdict(r);
|
|
377
377
|
assert.equal(r.json.token, null);
|
|
378
378
|
assert.deepEqual(r.json.violations, []);
|
|
379
|
+
assert.equal(r.stderr, "", "no --ledger and no default ledger is a standalone run that prints nothing");
|
|
379
380
|
|
|
380
381
|
const bad = f.baseEntries();
|
|
381
382
|
bad[0] = f.entry("survived", 0, { disposition: "defer" });
|
|
@@ -392,7 +393,7 @@ test("with no ledger the exit status is the verdict, and nothing is written to a
|
|
|
392
393
|
assert.equal(readFileSync(join(f.dir, "ledger.md"), "utf8"), ledgerBefore, "a ledger elsewhere is not this run's and is not touched");
|
|
393
394
|
});
|
|
394
395
|
|
|
395
|
-
test("an explicit --ledger naming no file is no ledger either: the default ledger is not borrowed,
|
|
396
|
+
test("an explicit --ledger naming no file is no ledger either: the default ledger is not borrowed, nothing is created, and stderr says so", (t) => {
|
|
396
397
|
const f = fixture(t);
|
|
397
398
|
const own = seedOwnLedger(f);
|
|
398
399
|
const ownBefore = readFileSync(own, "utf8");
|
|
@@ -403,6 +404,16 @@ test("an explicit --ledger naming no file is no ledger either: the default ledge
|
|
|
403
404
|
assert.equal(r.json.token, null);
|
|
404
405
|
assert.equal(readFileSync(own, "utf8"), ownBefore);
|
|
405
406
|
assert.equal(existsSync(join(f.dir, "absent")), false);
|
|
407
|
+
const lines = r.stderr.split("\n").filter(Boolean);
|
|
408
|
+
assert.equal(lines.length, 1, r.stderr);
|
|
409
|
+
assert.ok(lines[0].startsWith(`dispositions-check: no ledger at ${absent} `), lines[0]);
|
|
410
|
+
assert.match(lines[0], /no token was written.*--no-ledger/);
|
|
411
|
+
|
|
412
|
+
// A --ledger that exists is used, and draws no such note.
|
|
413
|
+
const present = standalone(f, "--repo", f.repo, "--ledger", own);
|
|
414
|
+
okVerdict(present);
|
|
415
|
+
assert.equal(present.json.token, `dispositions-ok=fix-pr-40:${f.head}`);
|
|
416
|
+
assert.doesNotMatch(present.stderr, /no ledger at/);
|
|
406
417
|
});
|
|
407
418
|
|
|
408
419
|
// Writes `f.repo`'s own `.fleet/ledger.md` with the member's row, as a fleet
|
|
@@ -479,6 +490,7 @@ test("--no-ledger is a standalone run whatever ledger the repository holds: a st
|
|
|
479
490
|
const r = standalone(f, "--repo", wt, "--no-ledger");
|
|
480
491
|
okVerdict(r);
|
|
481
492
|
assert.equal(r.json.token, null);
|
|
493
|
+
assert.equal(r.stderr, "", "--no-ledger is a chosen standalone run and prints nothing");
|
|
482
494
|
assert.equal(readFileSync(stale, "utf8"), before);
|
|
483
495
|
|
|
484
496
|
const bad = f.baseEntries();
|
|
@@ -495,6 +507,7 @@ test("--no-ledger leaves a ledger that holds the member's row unwritten, and con
|
|
|
495
507
|
const r = standalone(f, "--no-ledger");
|
|
496
508
|
okVerdict(r);
|
|
497
509
|
assert.equal(r.json.token, null);
|
|
510
|
+
assert.equal(r.stderr, "");
|
|
498
511
|
assert.equal(readFileSync(ledger, "utf8"), before);
|
|
499
512
|
|
|
500
513
|
const both = standalone(f, "--no-ledger", "--ledger", ledger);
|