@feigi/fleet-ctl 3.73.0 → 3.73.2
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 +1 -1
- package/scripts/main-checkout.mjs +18 -8
package/package.json
CHANGED
|
@@ -33,6 +33,10 @@
|
|
|
33
33
|
// switch and a switch back between two ticks; a stray commit pushed to `main`
|
|
34
34
|
// in a repository with no protecting ruleset. This is a backstop for
|
|
35
35
|
// accidents, not for adversaries.
|
|
36
|
+
// If the pack holding the baseline commit is unreadable, git reports exactly
|
|
37
|
+
// what it reports for a pruned commit, so the result is `missing`; an
|
|
38
|
+
// unopenable loose object or a broken alternate is `unknown` with a read
|
|
39
|
+
// cause instead (see `headMove`).
|
|
36
40
|
//
|
|
37
41
|
// THE PROTECTED SET is the non-ignored paths of the main checkout — what the
|
|
38
42
|
// member-write-guard protects — and its HEAD. `.fleet/`, `.worktrees/` and
|
|
@@ -144,8 +148,9 @@ function git(what, args, cwd, env) {
|
|
|
144
148
|
});
|
|
145
149
|
if (!r.error && r.status === 0) return { ok: true, stdout: r.stdout };
|
|
146
150
|
if (r.error) return { ok: false, why: `${what} did not run: ${r.error.code ?? r.error.message}`, status: null };
|
|
147
|
-
const
|
|
148
|
-
|
|
151
|
+
const stderr = String(r.stderr ?? "").trim();
|
|
152
|
+
const last = stderr.split("\n").at(-1);
|
|
153
|
+
return { ok: false, why: `${what} ${r.signal ? `killed by ${r.signal}` : `exited ${r.status}`}${last ? `: ${last}` : ""}`, status: r.status, stderr };
|
|
149
154
|
}
|
|
150
155
|
|
|
151
156
|
/** The main checkout `cwd` belongs to: `{ok, root}` or `{ok: false, why}`. */
|
|
@@ -301,10 +306,14 @@ function originMain(root, env) {
|
|
|
301
306
|
* read clean, while a stray commit, a reset or an amend do not. `origin/main`
|
|
302
307
|
* is read even when HEAD equals the baseline: a checkout that cannot name it
|
|
303
308
|
* is one this cannot vouch for.
|
|
304
|
-
* A failed ancestry read is followed by `git
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
309
|
+
* A failed ancestry read is followed by `git rev-parse -q --verify B^{commit}`.
|
|
310
|
+
* Only exit 1 with nothing on stderr is the missing answer: that is what an
|
|
311
|
+
* absent commit gives. Exit 1 with anything on stderr means git could not
|
|
312
|
+
* settle absence — an unopenable loose object, a broken alternate, an object
|
|
313
|
+
* that is not a commit, or output unrelated to the object such as GIT_TRACE's
|
|
314
|
+
* — and that read's own failure is returned, so `why` carries what git
|
|
315
|
+
* printed. Anything else, a corrupt object's exit 128 included, keeps the
|
|
316
|
+
* ancestry failure.
|
|
308
317
|
*/
|
|
309
318
|
function headMove(root, env, was, now) {
|
|
310
319
|
const origin = originMain(root, env);
|
|
@@ -315,8 +324,9 @@ function headMove(root, env, was, now) {
|
|
|
315
324
|
const ancestor = git("git merge-base --is-ancestor", ["merge-base", "--is-ancestor", was.oid, now.oid], root, env);
|
|
316
325
|
if (!ancestor.ok) {
|
|
317
326
|
if (ancestor.status === 1) return moved;
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
327
|
+
const probe = git("git rev-parse --verify", ["rev-parse", "-q", "--verify", `${was.oid}^{commit}`], root, env);
|
|
328
|
+
if (probe.ok || probe.status !== 1) return ancestor;
|
|
329
|
+
if (probe.stderr !== "") return probe;
|
|
320
330
|
return { ok: false, missing: true, why: `baseline commit ${was.oid.slice(0, 7)} is missing from this repository; HEAD is ${headLabel(now)}` };
|
|
321
331
|
}
|
|
322
332
|
const stray = git("git rev-list", ["rev-list", "--max-count=1", `${was.oid}..${now.oid}`, "^refs/remotes/origin/main"], root, env);
|