@feigi/fleet-ctl 3.23.35 → 3.23.37
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 +1 -1
- package/scripts/member-write-guard.mjs +1 -1
- package/scripts/repo-root.mjs +1 -1
- package/skills/run-team/references/reaping.md +1 -1
- package/scripts/agent-test-dir-prose.test.mjs +0 -59
- package/scripts/agent-test.test.mjs +0 -1640
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +0 -397
- package/scripts/ambient-git-vars-prose.test.mjs +0 -192
- package/scripts/ancestry-check-position-prose.test.mjs +0 -175
- package/scripts/apply-ruleset.test.mjs +0 -421
- package/scripts/arg-header-probes-prose.test.mjs +0 -394
- package/scripts/arg.test.mjs +0 -1354
- package/scripts/board-cli.test.mjs +0 -710
- package/scripts/board-identity.test.mjs +0 -429
- package/scripts/board-liveness-banner.test.mjs +0 -119
- package/scripts/board-prev-shape.test.mjs +0 -228
- package/scripts/board-tryparse-null.test.mjs +0 -119
- package/scripts/board.test.mjs +0 -3121
- package/scripts/brief-after-cut-prose.test.mjs +0 -53
- package/scripts/candidates-exit3-prose.test.mjs +0 -302
- package/scripts/candidates.test.mjs +0 -2312
- package/scripts/caveat-unification-prose.test.mjs +0 -98
- package/scripts/cell-readout.test.mjs +0 -615
- package/scripts/ci-comment-rot-prose.test.mjs +0 -2025
- package/scripts/ci-completes-premise-prose.test.mjs +0 -257
- package/scripts/ci-state-prose.test.mjs +0 -113
- package/scripts/ci-state.test.mjs +0 -1933
- package/scripts/ci-vacuous-green.test.mjs +0 -368
- package/scripts/citation-sweep-prose.test.mjs +0 -1712
- package/scripts/claim-lifecycle.test.mjs +0 -187
- package/scripts/claim-ticket.test.mjs +0 -1122
- package/scripts/closing-keyword-prose.test.mjs +0 -193
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +0 -165
- package/scripts/cockpit-tick-nonblocking.test.mjs +0 -210
- package/scripts/compute-board.test.mjs +0 -1214
- package/scripts/compute-spend.test.mjs +0 -517
- package/scripts/consumer-technology-prose.test.mjs +0 -126
- package/scripts/cross-repo-citation-prose.test.mjs +0 -155
- package/scripts/cwd-isolation-pins.mjs +0 -83
- package/scripts/dedupe-guard-prose.test.mjs +0 -243
- package/scripts/delete-merged-branch.test.mjs +0 -576
- package/scripts/derive-testcmd.test.mjs +0 -595
- package/scripts/diff-stats.test.mjs +0 -404
- package/scripts/dispatch-block-golden-prose.test.mjs +0 -1130
- package/scripts/dispatch-block-pins-prose.test.mjs +0 -615
- package/scripts/dispositions-check.test.mjs +0 -936
- package/scripts/dispositions-gate-prose.test.mjs +0 -129
- package/scripts/drop-merged-label.test.mjs +0 -479
- package/scripts/exec-stub.mjs +0 -93
- package/scripts/exec-stub.test.mjs +0 -69
- package/scripts/expected-jobs-prose.test.mjs +0 -80
- package/scripts/fan-out-authorization-prose.test.mjs +0 -80
- package/scripts/filing-bar-seat-prose.test.mjs +0 -242
- package/scripts/filing-claim-bar-prose.test.mjs +0 -166
- package/scripts/finisher-died-prose.test.mjs +0 -31
- package/scripts/finisher-dispatch-premise-prose.test.mjs +0 -312
- package/scripts/finisher-halt-prose.test.mjs +0 -106
- package/scripts/finisher-name-prose.test.mjs +0 -134
- package/scripts/finisher-own-tree-prose.test.mjs +0 -299
- package/scripts/finisher-pin-race-prose.test.mjs +0 -339
- package/scripts/finisher-test-verdict-prose.test.mjs +0 -102
- package/scripts/fix-applier-correction-rules-prose.test.mjs +0 -202
- package/scripts/fix-applier-result-file-prose.test.mjs +0 -149
- package/scripts/fleet-bootstrap.test.mjs +0 -75
- package/scripts/fleet-heartbeat.test.mjs +0 -450
- package/scripts/fleet-provenance.test.mjs +0 -138
- package/scripts/fleet-run.test.mjs +0 -90
- package/scripts/fleet-state.test.mjs +0 -460
- package/scripts/fleet-tick-prose.test.mjs +0 -300
- package/scripts/fleet-tick.test.mjs +0 -2444
- package/scripts/force-with-lease-reason-prose.test.mjs +0 -184
- package/scripts/frontmatter-check.test.mjs +0 -436
- package/scripts/git-env.test.mjs +0 -149
- package/scripts/git-status-untracked-mode-sweep.test.mjs +0 -216
- package/scripts/gone-walk.test.mjs +0 -213
- package/scripts/gp-sep-invariant-prose.test.mjs +0 -188
- package/scripts/head-moved-after-label-prose.test.mjs +0 -233
- package/scripts/immutable-body-claim-prose.test.mjs +0 -204
- package/scripts/implementer-model-tier.test.mjs +0 -235
- package/scripts/inflight-citation-prose.test.mjs +0 -144
- package/scripts/inflight-exit2-prose.test.mjs +0 -81
- package/scripts/inflight-probe-guard-prose.test.mjs +0 -109
- package/scripts/inflight-scan-scope-prose.test.mjs +0 -57
- package/scripts/inflight.test.mjs +0 -2882
- package/scripts/injection-control-prose.test.mjs +0 -404
- package/scripts/install-root-audit.test.mjs +0 -464
- package/scripts/instrument-check-prose.test.mjs +0 -235
- package/scripts/instruments.test.mjs +0 -787
- package/scripts/is-cli.test.mjs +0 -99
- package/scripts/issue-tracker-prose.test.mjs +0 -71
- package/scripts/json.test.mjs +0 -364
- package/scripts/ledger-dispatch.test.mjs +0 -927
- package/scripts/ledger-grammar.test.mjs +0 -227
- package/scripts/ledger-read-require-file.test.mjs +0 -197
- package/scripts/ledger-rotate.test.mjs +0 -142
- package/scripts/ledger.test.mjs +0 -3436
- package/scripts/line-distance-prose.test.mjs +0 -245
- package/scripts/liveness-rationale-prose.test.mjs +0 -83
- package/scripts/locale-pin-prose.test.mjs +0 -189
- package/scripts/main-checkout.test.mjs +0 -332
- package/scripts/member-outcome-prose.test.mjs +0 -167
- package/scripts/member-outcomes-header.test.mjs +0 -129
- package/scripts/member-outcomes-prose.test.mjs +0 -63
- package/scripts/member-outcomes.test.mjs +0 -638
- package/scripts/member-prompt-prose.test.mjs +0 -165
- package/scripts/member-record.test.mjs +0 -541
- package/scripts/member-write-guard.test.mjs +0 -214
- package/scripts/merge-commit-probe-prose.test.mjs +0 -122
- package/scripts/merge-gate.test.mjs +0 -613
- package/scripts/muted-git-guard-sweep.test.mjs +0 -493
- package/scripts/net-ssh-precedence-prose.test.mjs +0 -91
- package/scripts/net-watchdog-prose.test.mjs +0 -79
- package/scripts/net.test.mjs +0 -211
- package/scripts/no-ci-gate-prose.test.mjs +0 -108
- package/scripts/no-undo-audit.test.mjs +0 -3961
- package/scripts/no-wave.test.mjs +0 -138
- package/scripts/node-floor-sweep.test.mjs +0 -611
- package/scripts/pointer-target-prose.test.mjs +0 -186
- package/scripts/pr-cost.test.mjs +0 -521
- package/scripts/pr-overlap.test.mjs +0 -692
- package/scripts/printf-die-sweep.test.mjs +0 -384
- package/scripts/prompt-renderer.mjs +0 -40
- package/scripts/prompt-renderer.test.mjs +0 -68
- package/scripts/prose-pin.mjs +0 -807
- package/scripts/prose-pin.test.mjs +0 -1034
- package/scripts/prove-merge.test.mjs +0 -995
- package/scripts/pull-table-relabel-prose.test.mjs +0 -60
- package/scripts/quiet-payload-prose.test.mjs +0 -222
- package/scripts/reap-cherry-check-prose.test.mjs +0 -80
- package/scripts/reap.test.mjs +0 -4432
- package/scripts/reaping-prose.test.mjs +0 -239
- package/scripts/reaping-reap-authorizers-prose.test.mjs +0 -112
- package/scripts/reaping-release-authorizers-prose.test.mjs +0 -85
- package/scripts/recipe-derivation-prose.test.mjs +0 -112
- package/scripts/recipe-prove.test.mjs +0 -1042
- package/scripts/refuter-scratch-prose.test.mjs +0 -135
- package/scripts/release-label-required-prose.test.mjs +0 -71
- package/scripts/release-label-split-prose.test.mjs +0 -184
- package/scripts/release-ticket-reap-pairing-prose.test.mjs +0 -63
- package/scripts/release-ticket.test.mjs +0 -5099
- package/scripts/renovate-release-contract.test.mjs +0 -379
- package/scripts/repo-root.test.mjs +0 -873
- package/scripts/reporter-output-rule-prose.test.mjs +0 -208
- package/scripts/review-agent-report-only.test.mjs +0 -49
- package/scripts/review-core-booking.test.mjs +0 -35
- package/scripts/review-core-cwd-isolation.test.mjs +0 -374
- package/scripts/review-core-reads.test.mjs +0 -478
- package/scripts/review-core-refuter-scratch.test.mjs +0 -148
- package/scripts/review-core-scratch-refusal.test.mjs +0 -64
- package/scripts/review-core-shared-test-run.test.mjs +0 -275
- package/scripts/review-core-snapshot-path.test.mjs +0 -830
- package/scripts/review-core-specialist-scratch.test.mjs +0 -191
- package/scripts/review-core-testcmd.test.mjs +0 -335
- package/scripts/review-core-unrun.test.mjs +0 -566
- package/scripts/review-core-unverified-discriminant.test.mjs +0 -208
- package/scripts/review-eval-resolver-path.test.mjs +0 -55
- package/scripts/review-host-fixture.mjs +0 -89
- package/scripts/review-in-run-retry.test.mjs +0 -211
- package/scripts/review-no-vendor-dispatch.test.mjs +0 -45
- package/scripts/review-path-default.test.mjs +0 -796
- package/scripts/review-runner-spawns.test.mjs +0 -95
- package/scripts/review-runner.test.mjs +0 -166
- package/scripts/review-tier-audit.test.mjs +0 -140
- package/scripts/run-artifact-pr-prose.test.mjs +0 -341
- package/scripts/run-merge-bot-prose.test.mjs +0 -1413
- package/scripts/run-team-local-hook.test.mjs +0 -442
- package/scripts/scratch-partition-invariant-prose.test.mjs +0 -74
- package/scripts/scripts-path-citation-sweep.test.mjs +0 -73
- package/scripts/section-between-guard-prose.test.mjs +0 -379
- package/scripts/select-dimensions.test.mjs +0 -674
- package/scripts/shared-refusal.test.mjs +0 -388
- package/scripts/shell-traps-prose.test.mjs +0 -504
- package/scripts/shortlist.test.mjs +0 -380
- package/scripts/slow-transport.mjs +0 -72
- package/scripts/snapshot-repo.test.mjs +0 -1006
- package/scripts/snapshot-runner-audience-prose.test.mjs +0 -130
- package/scripts/spend-view.test.mjs +0 -312
- package/scripts/staleness-qualifier-prose.test.mjs +0 -251
- package/scripts/staleness-verdict-prose.test.mjs +0 -142
- package/scripts/staleness.test.mjs +0 -893
- package/scripts/stalled-member-liveness-prose.test.mjs +0 -219
- package/scripts/stash-prohibition-prose.test.mjs +0 -313
- package/scripts/strip-comments.mjs +0 -44
- package/scripts/temp-dir.mjs +0 -47
- package/scripts/ticket-router.test.mjs +0 -981
- package/scripts/tier-check.test.mjs +0 -828
- package/scripts/tier-outcomes-header.test.mjs +0 -518
- package/scripts/tier-outcomes.test.mjs +0 -572
- package/scripts/tier-roles.test.mjs +0 -535
- package/scripts/tracker-block-copy-prose.test.mjs +0 -288
- package/scripts/triage-labels-gloss-prose.test.mjs +0 -97
- package/scripts/unattended-git-sweep.test.mjs +0 -142
- package/scripts/verify-sha-exit2-prose.test.mjs +0 -269
- package/scripts/verify-sha.test.mjs +0 -692
- package/scripts/watcher-degraded-block.test.mjs +0 -369
- package/scripts/watcher-key-prose.test.mjs +0 -106
- package/scripts/within-run-pair-prose.test.mjs +0 -212
- package/scripts/worktree-audit.test.mjs +0 -1408
- package/scripts/worktree-head-prose.test.mjs +0 -276
- package/scripts/worktree-listing-sweep.test.mjs +0 -217
- package/scripts/worktree-model-prose.test.mjs +0 -216
- package/scripts/worktree-porcelain.mjs +0 -35
- package/scripts/worktree-porcelain.test.mjs +0 -102
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
// Regression gate for #578, and the durable half of a fix that has now been
|
|
2
|
-
// declared complete twice and been wrong twice.
|
|
3
|
-
//
|
|
4
|
-
// The class: a guard that suppresses git's own stderr and then `die`s with a
|
|
5
|
-
// message the script cannot know to be the cause. #559 fixed it in
|
|
6
|
-
// verify-sha.sh and recorded that as the sweep. #566 then found prove-merge.sh
|
|
7
|
-
// and stated IT was the last instance. #578 found five more. The per-site fix
|
|
8
|
-
// is not what fails here — the enumeration is, every time. So this file stops
|
|
9
|
-
// enumerating and asks git what ships.
|
|
10
|
-
//
|
|
11
|
-
// The mechanism, measured (git 2.50.1 Apple Git-155, throwaway repo) rather
|
|
12
|
-
// than inferred:
|
|
13
|
-
//
|
|
14
|
-
// $ git rev-parse --verify --quiet nosuchref # exit 1, 0 bytes of stderr
|
|
15
|
-
// $ git rev-parse -q --verify nosuchref # exit 1, 0 bytes of stderr
|
|
16
|
-
// $ git rev-parse --verify nosuchref # exit 128, `fatal: Needed a single revision`
|
|
17
|
-
//
|
|
18
|
-
// So the suppression is the whole defect, and removing it is the whole fix.
|
|
19
|
-
//
|
|
20
|
-
// `-q` and `--quiet` are the WHOLE spelling surface, measured rather than
|
|
21
|
-
// assumed: `git rev-parse` does not take abbreviated long options, so the
|
|
22
|
-
// near-misses are not synonyms and need no pattern of their own —
|
|
23
|
-
// `--quie`, `--qui`, `--qu` and `--q` each come back exit 128 with `fatal:
|
|
24
|
-
// Needed a single revision`, i.e. treated as a revision argument, not as
|
|
25
|
-
// `--quiet`. (`--veri` likewise is not `--verify`: it exits 0 and verifies
|
|
26
|
-
// nothing, which the `--verify` test below catches as a missing `--verify`.)
|
|
27
|
-
//
|
|
28
|
-
// `--verify` is the other half, and it looks redundant next to a dropped
|
|
29
|
-
// `--quiet` — which is exactly why it is pinned below rather than left to a
|
|
30
|
-
// comment. Measured:
|
|
31
|
-
//
|
|
32
|
-
// $ git rev-parse f.txt # prints `f.txt`, exit 0
|
|
33
|
-
// $ git rev-parse --verify f.txt # exit 128
|
|
34
|
-
//
|
|
35
|
-
// Without it a `$base` that names a FILE clears the guard and the script
|
|
36
|
-
// proceeds on something that is not a ref.
|
|
37
|
-
//
|
|
38
|
-
// WHAT IS AND IS NOT IN THE CLASS. The discriminator is which OUTCOME is
|
|
39
|
-
// fatal, and it is not a stylistic tell — the two shapes want opposite things:
|
|
40
|
-
//
|
|
41
|
-
// failure is fatal git's reason is the missing information, and the guard
|
|
42
|
-
// is silent on an unambiguous success. Unmute it.
|
|
43
|
-
// success is fatal (`&& die`, `&& has_branch=true`) failure is the
|
|
44
|
-
// EXPECTED answer — a branch-existence probe asking
|
|
45
|
-
// whether a name is free. Unmuting prints `fatal: Needed
|
|
46
|
-
// a single revision` on every HEALTHY run. `--quiet` is
|
|
47
|
-
// load-bearing; leave it. Measured: exit 1 / 0 bytes
|
|
48
|
-
// muted, exit 128 / 32 bytes not.
|
|
49
|
-
//
|
|
50
|
-
// "Failure is fatal" is read off the SHAPE, not off one spelling of it: the
|
|
51
|
-
// sweep below joins shell's own line continuations first, so `|| die`,
|
|
52
|
-
// `|| { die …; }`, a `||` left dangling at end of line, and
|
|
53
|
-
// `if ! … ; then die` are one population, and a guard escapes by being
|
|
54
|
-
// correct rather than by being written differently. Each of those spellings,
|
|
55
|
-
// and each way a comment could move a verdict, has a fixture in
|
|
56
|
-
// `SHAPES` below — a sweep whose own blind spots are only argued for is this
|
|
57
|
-
// ticket repeating.
|
|
58
|
-
//
|
|
59
|
-
// Deliberately outside this sweep, each with its reason:
|
|
60
|
-
//
|
|
61
|
-
// - `fetch --quiet` (prove-merge.sh, reap.sh, verify-sha.sh). Measured
|
|
62
|
-
// against a broken remote: 196 bytes of `fatal:` still reach stderr,
|
|
63
|
-
// because `--quiet` suppresses progress, not diagnosis. Nothing is muted.
|
|
64
|
-
// - The `2>/dev/null` probes. An adjacent mechanism, tracked in #481, #482
|
|
65
|
-
// and #391, and not this one.
|
|
66
|
-
// - Captures (`tip=$(git rev-parse …)`), which suppress nothing — a capture
|
|
67
|
-
// is read, so git's diagnosis reaches the operator on failure whether or
|
|
68
|
-
// not `--verify` is present. verify-sha.sh had one without `--verify`,
|
|
69
|
-
// a real defect of a DIFFERENT mechanism (#1146 fixed it: the capture now
|
|
70
|
-
// carries `--verify`, so a working-directory path can no longer clear it
|
|
71
|
-
// at exit 0). Whether captures join THIS sweep is a separate decision,
|
|
72
|
-
// left open rather than folded in here — #1146 is one fixed site, not a
|
|
73
|
-
// general capture audit. The `>/dev/null` clause in the `--verify` test
|
|
74
|
-
// below is what keeps captures out structurally, regardless of that
|
|
75
|
-
// decision.
|
|
76
|
-
//
|
|
77
|
-
// Comment text inside the shell scripts is stripped before any of this, and
|
|
78
|
-
// the strip is quote-aware. Not because some sentence happens to trip the
|
|
79
|
-
// scan today — it does not — but because prose about this defect is exactly
|
|
80
|
-
// what a contributor writes NEXT TO a guard, in both directions: a `--quiet`
|
|
81
|
-
// in a trailing comment on an already-correct line must not raise a false
|
|
82
|
-
// failure, and a `--verify` in a trailing comment must not silence a real one.
|
|
83
|
-
// Both directions are pinned in `SHAPES`. Quote-aware, because a `#` inside a
|
|
84
|
-
// `die` message is text, not the start of a comment.
|
|
85
|
-
//
|
|
86
|
-
// This file is `.mjs` and the sweep reads `*.sh`, so it cannot match its own
|
|
87
|
-
// prose or its own fixtures — the failure mode where a check quotes the
|
|
88
|
-
// pattern it greps for and reports on itself.
|
|
89
|
-
//
|
|
90
|
-
// KNOWN LIMIT: the sweep half of this file needs an ambient `.git` (see `ROOT`
|
|
91
|
-
// below). Where there is none — a bare `git archive` extraction, which is how
|
|
92
|
-
// review specialists used to measure the suite (#1056; the review snapshot is
|
|
93
|
-
// `git init`ed at cut time now, so these run there) — those tests DECLINE, with
|
|
94
|
-
// a reason, rather than running: the tree they would police is not reachable
|
|
95
|
-
// from here.
|
|
96
|
-
// The fixture tests below run against literal strings and the behaviour tests
|
|
97
|
-
// build their own repositories — both hold anywhere, so neither is gated. Until #1149 the same condition was an
|
|
98
|
-
// uncaught throw at module load, which node could only report as one synthetic
|
|
99
|
-
// failing test at line 1 of this file.
|
|
100
|
-
//
|
|
101
|
-
// Zero deps: `node --test plugin/scripts/muted-git-guard-sweep.test.mjs`.
|
|
102
|
-
|
|
103
|
-
import { test } from "node:test";
|
|
104
|
-
import assert from "node:assert/strict";
|
|
105
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
106
|
-
import { mkdtempSync, realpathSync, rmSync, writeFileSync } from "node:fs";
|
|
107
|
-
import { readFileSync } from "node:fs";
|
|
108
|
-
import { tmpdir } from "node:os";
|
|
109
|
-
import { join } from "node:path";
|
|
110
|
-
import { fileURLToPath } from "node:url";
|
|
111
|
-
import { repoRoot, skipWithoutRepo, trackedShellScripts } from "./repo-root.mjs";
|
|
112
|
-
|
|
113
|
-
const DIR = fileURLToPath(new URL(".", import.meta.url));
|
|
114
|
-
|
|
115
|
-
// Asks git what ships rather than walking the directory: an untracked scratch
|
|
116
|
-
// script is not what ships, and a fleet script that moves out of this directory
|
|
117
|
-
// must not fall out of the sweep with it. Same rule, and same reason, as
|
|
118
|
-
// unattended-git-sweep.test.mjs. Needs an ambient working tree, and answers
|
|
119
|
-
// `null` rather than throwing where there is none (#1149).
|
|
120
|
-
const ROOT = repoRoot(DIR);
|
|
121
|
-
const SKIP_WITHOUT_REPO = skipWithoutRepo(ROOT, "the sweep over what ships");
|
|
122
|
-
// Empty ONLY because the root lookup could not answer, in which case every test
|
|
123
|
-
// that reads it is skipped. A root that answers and lists nothing is a different
|
|
124
|
-
// condition — the wrong repository, or a broken glob — and it must reach the
|
|
125
|
-
// non-vacuity guard below and fail there.
|
|
126
|
-
const SHELL_SCRIPTS = ROOT === null ? [] : trackedShellScripts(ROOT);
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Drop a trailing `#` comment. Quote-aware: a `#` inside a `die` message is
|
|
130
|
-
* text — stripping at it would truncate the guard and lose the `|| die` that
|
|
131
|
-
* classifies it.
|
|
132
|
-
*/
|
|
133
|
-
function stripComment(line) {
|
|
134
|
-
let quote = null;
|
|
135
|
-
for (let i = 0; i < line.length; i++) {
|
|
136
|
-
const c = line[i];
|
|
137
|
-
if (quote) {
|
|
138
|
-
if (c === quote) quote = null;
|
|
139
|
-
else if (c === "\\" && quote === '"') i++;
|
|
140
|
-
} else if (c === "'" || c === '"') {
|
|
141
|
-
quote = c;
|
|
142
|
-
} else if (c === "#" && (i === 0 || /\s/.test(line[i - 1]))) {
|
|
143
|
-
return line.slice(0, i);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return line;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* One logical shell statement per element, comments already gone.
|
|
151
|
-
*
|
|
152
|
-
* Joined, because a guard's `die` routinely sits on a later physical line and
|
|
153
|
-
* a per-line scan then classifies it as having no `die` at all — silently
|
|
154
|
-
* exempting the very sites this ticket is about. Three continuations ship in
|
|
155
|
-
* this codebase and all three are joined: a trailing backslash, a bare `||`
|
|
156
|
-
* or `&&` left at end of line (shell continues on its own — release-ticket.sh
|
|
157
|
-
* and inflight.sh both use it), and `then` at end of line for the
|
|
158
|
-
* `if ! … ; then` / newline / `die` shape.
|
|
159
|
-
*
|
|
160
|
-
* Comments are stripped BEFORE joining, so a sentence ending in `||` cannot
|
|
161
|
-
* glue two unrelated statements together.
|
|
162
|
-
*
|
|
163
|
-
* Ceiling: the `then` join reaches the first statement of the branch, not the
|
|
164
|
-
* whole branch. A `die` three lines into an `if !` body is not seen. Every
|
|
165
|
-
* guard of this class in this codebase is one statement; widen the join if
|
|
166
|
-
* that stops being true.
|
|
167
|
-
*/
|
|
168
|
-
function statements(text) {
|
|
169
|
-
return text
|
|
170
|
-
.split("\n").map(stripComment).join("\n")
|
|
171
|
-
.replace(/\\\n[ \t]*/g, " ")
|
|
172
|
-
.replace(/(\|\||&&|\bthen)[ \t]*\n[ \t]*/g, "$1 ")
|
|
173
|
-
.split("\n")
|
|
174
|
-
.map((l) => l.trim())
|
|
175
|
-
.filter(Boolean);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* The `git … rev-parse …` command itself, cut at the first redirection, pipe,
|
|
180
|
-
* list operator or `$(` close.
|
|
181
|
-
*
|
|
182
|
-
* Flags are read off THIS, never off the whole statement: `--quiet` in a `die`
|
|
183
|
-
* message and `--verify` in a trailing comment are prose about the guard, not
|
|
184
|
-
* arguments to it, and neither may move a verdict.
|
|
185
|
-
*/
|
|
186
|
-
function revParseCmd(statement) {
|
|
187
|
-
const m = /\bgit\b.*?\brev-parse\b/.exec(statement);
|
|
188
|
-
return m ? statement.slice(m.index).split(/\s*\d?[<>|;&)]/)[0] : "";
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** Every `git rev-parse` invocation a script ships, as { path, line, cmd }. */
|
|
192
|
-
function scan(path, text) {
|
|
193
|
-
return statements(text)
|
|
194
|
-
.filter((line) => /\bgit\b.*\brev-parse\b/.test(line))
|
|
195
|
-
.map((line) => ({ path, line, cmd: revParseCmd(line) }));
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Every rev-parse line in what ships, read on first use rather than at module
|
|
200
|
-
* scope.
|
|
201
|
-
*
|
|
202
|
-
* Module scope is what #1149 is about: a read that throws there is a throw node
|
|
203
|
-
* cannot attribute to any test, so it reports one synthetic failure at line 1
|
|
204
|
-
* and the file's other tests never run. Deferred into the tests, an unreadable
|
|
205
|
-
* tracked script fails the test that needed it, by name, and the fixture tests
|
|
206
|
-
* — which need no repository at all — still report.
|
|
207
|
-
*/
|
|
208
|
-
let cachedAll;
|
|
209
|
-
const all = () => (cachedAll ??= SHELL_SCRIPTS.flatMap((p) => scan(p, readFileSync(join(ROOT, p), "utf8"))));
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Does a FAILURE of this rev-parse end the script? That — not `|| die`
|
|
213
|
-
* literally — is the population: `|| { die …; }` and `if ! … ; then die` are
|
|
214
|
-
* the same guard. `&& die` is the opposite shape and stays out by construction.
|
|
215
|
-
*/
|
|
216
|
-
const failureIsFatal = (g) => /\|\|\s*\{?\s*die\b/.test(g.line)
|
|
217
|
-
|| /^if\s+!\s.*\bthen\b.*\bdie\b/.test(g.line);
|
|
218
|
-
|
|
219
|
-
/** `-q` and `--quiet` are exact synonyms and the whole surface — see the header. */
|
|
220
|
-
const isMuted = (g) => /(?:^|\s)(?:-q|--quiet)(?=\s|$)/.test(g.cmd);
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Does this rev-parse name a REF, as opposed to asking about the repository?
|
|
224
|
-
* `--git-dir`, `--show-toplevel`, `--absolute-git-dir` and friends take no rev
|
|
225
|
-
* operand, which is why they are exempt — a property of the call, not a list of
|
|
226
|
-
* script names to keep up to date.
|
|
227
|
-
*/
|
|
228
|
-
const resolvesARef = (g) => {
|
|
229
|
-
const words = g.cmd.split(/\s+/);
|
|
230
|
-
const rest = words.slice(words.indexOf("rev-parse") + 1);
|
|
231
|
-
return rest.some((w, i) => !w.startsWith("-") && rest[i - 1] !== "--git-path");
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// The two verdicts, written once. The fixtures below and the sweep over what
|
|
235
|
-
// ships must ask the SAME question, or the fixtures stop defending anything.
|
|
236
|
-
const isMutedGuard = (g) => failureIsFatal(g) && isMuted(g);
|
|
237
|
-
const isUnverifiedGuard = (g) => failureIsFatal(g)
|
|
238
|
-
&& />\/dev\/null/.test(g.line)
|
|
239
|
-
&& resolvesARef(g)
|
|
240
|
-
&& !/--verify\b/.test(g.cmd);
|
|
241
|
-
|
|
242
|
-
test("the sweep sees the scripts it is supposed to police", { skip: SKIP_WITHOUT_REPO }, () => {
|
|
243
|
-
// A guard on the guard: a bad glob, a moved directory or a `git ls-files`
|
|
244
|
-
// that answers nothing turns every assertion below into a vacuous pass over
|
|
245
|
-
// an empty list — green, and blind. Named scripts, because those are the ones
|
|
246
|
-
// whose defect this file exists to hold shut.
|
|
247
|
-
for (const s of ["no-undo-audit.sh", "worktree-audit.sh", "release-ticket.sh", "reap.sh", "prove-merge.sh"]) {
|
|
248
|
-
assert.ok(
|
|
249
|
-
all().some((g) => g.path.endsWith(`/${s}`)),
|
|
250
|
-
`${s} contributed no rev-parse line to the sweep — the file list or the join above is broken, not the script`,
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
test("no fatal rev-parse guard suppresses git's own diagnosis", { skip: SKIP_WITHOUT_REPO }, () => {
|
|
256
|
-
const muted = all().filter(isMutedGuard);
|
|
257
|
-
assert.deepEqual(
|
|
258
|
-
muted.map((g) => `${g.path}: ${g.line}`),
|
|
259
|
-
[],
|
|
260
|
-
"each of these dies on a failure whose reason only git knows, and `-q`/`--quiet` throws that reason away. "
|
|
261
|
-
+ "Drop it — keep `--verify`. If the failure here is the EXPECTED answer, the guard wants `&& …`, not `|| die`.",
|
|
262
|
-
);
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
test("every rev-parse resolution guard keeps --verify", { skip: SKIP_WITHOUT_REPO }, () => {
|
|
266
|
-
// The regression a reader "tidying up" after the fix would introduce, and the
|
|
267
|
-
// one a comment alone does not survive.
|
|
268
|
-
//
|
|
269
|
-
// Scoped by shape, not by variable name: a fatal guard that DISCARDS stdout
|
|
270
|
-
// and names a ref exists only to ask whether that name resolves, whatever the
|
|
271
|
-
// variable holding it is called. Keying on `"$base"`/`"$sha"` instead would be
|
|
272
|
-
// the enumerate-by-name failure this file's header condemns.
|
|
273
|
-
//
|
|
274
|
-
// A CAPTURE (`tip=$(git rev-parse …)`) is deliberately out, which is what the
|
|
275
|
-
// `>/dev/null` clause buys. It asks a different question — the value, not the
|
|
276
|
-
// yes/no — and it suppresses nothing, so git's diagnosis already reaches the
|
|
277
|
-
// operator there. verify-sha.sh had one without `--verify`; measured, with a
|
|
278
|
-
// file `origin/weird` present `git rev-parse "origin/weird"` exits 0 and
|
|
279
|
-
// prints the path, so that capture could carry a non-sha onward. Real, and a
|
|
280
|
-
// different mechanism: fixed at its own site by #1146 rather than widened
|
|
281
|
-
// into here. The fixture for this exclusion stays in the BARE spelling for
|
|
282
|
-
// the reason recorded on it — it is what pins the `>/dev/null` clause — so
|
|
283
|
-
// it deliberately no longer matches what verify-sha.sh ships.
|
|
284
|
-
const unverified = all().filter(isUnverifiedGuard);
|
|
285
|
-
assert.deepEqual(
|
|
286
|
-
unverified.map((g) => `${g.path}: ${g.line}`),
|
|
287
|
-
[],
|
|
288
|
-
"without `--verify`, `git rev-parse <a-file-path>` prints the path and exits 0, so a ref argument naming a FILE clears the guard",
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
// The sweep's own blind spots, pinned. Every escape below was a real hole in
|
|
293
|
-
// the first version of this file: each ships the identical defect, and each was
|
|
294
|
-
// green. `verdict` is what the two static tests above must now say.
|
|
295
|
-
const SHAPES = [
|
|
296
|
-
{ why: "the long spelling", muted: true, src: 'git rev-parse --quiet --verify "$base" >/dev/null || die "no"' },
|
|
297
|
-
{ why: "`-q`, an exact synonym", muted: true, src: 'git rev-parse -q --verify "$base" >/dev/null || die "no"' },
|
|
298
|
-
{ why: "`-q` written after `--verify`", muted: true, src: 'git rev-parse --verify -q "$base" >/dev/null || die "no"' },
|
|
299
|
-
{ why: "a backslash continuation", muted: true, src: 'git rev-parse -q --verify "$base" >/dev/null \\\n || die "no"' },
|
|
300
|
-
{ why: "a bare `||` left at end of line", muted: true, src: 'git rev-parse -q --verify "$base" >/dev/null ||\n die "no"' },
|
|
301
|
-
{ why: "a braced die", muted: true, src: 'git rev-parse -q --verify "$base" >/dev/null || { die "no"; }' },
|
|
302
|
-
{ why: "`if ! … ; then die`", muted: true, src: 'if ! git rev-parse -q --verify "$base" >/dev/null; then\n die "no"\nfi' },
|
|
303
|
-
{ why: "a trailing comment must not hide a real one", muted: true, src: 'git rev-parse -q --verify "$base" >/dev/null || die "no" # fixed in #578' },
|
|
304
|
-
{ why: "`-C` before the subcommand", muted: true, src: 'git -C "$wt" rev-parse -q --verify "$base" >/dev/null || die "no"' },
|
|
305
|
-
|
|
306
|
-
{ why: "an already-correct guard", muted: false, src: 'git rev-parse --verify "$base" >/dev/null || die "no"' },
|
|
307
|
-
{ why: "a `--quiet` in a trailing comment must not raise a false failure", muted: false, src: 'git rev-parse --verify "$base" >/dev/null || die "no" # never add --quiet here' },
|
|
308
|
-
{ why: "a `--quiet` in the die message is prose, not an argument", muted: false, src: 'git rev-parse --verify "$b" >/dev/null || die "unresolved; never silence this with --quiet again"' },
|
|
309
|
-
{ why: "a `|| die` inside a comment must not make a probe look fatal", muted: false, src: 'git rev-parse --verify --quiet "refs/heads/$b" >/dev/null && has_branch=true # not a || die site: failure is the answer' },
|
|
310
|
-
{ why: "a whole-line comment is not code", muted: false, src: '# git rev-parse --quiet --verify "$base" >/dev/null || die "no"' },
|
|
311
|
-
{ why: "success-is-fatal: a branch-existence probe wants --quiet", muted: false, src: 'git rev-parse --verify --quiet "refs/heads/$b" >/dev/null && die "branch exists"' },
|
|
312
|
-
{ why: "a `#` inside the message must not truncate the guard", muted: false, src: 'git rev-parse --verify "$b" >/dev/null || die "$b does not resolve (see #578)"' },
|
|
313
|
-
];
|
|
314
|
-
|
|
315
|
-
const REFS = [
|
|
316
|
-
{ why: "a differently-named ref variable still escapes nothing", unverified: true, src: 'git rev-parse "$candidate" >/dev/null || die "no"' },
|
|
317
|
-
{ why: "a `--verify` in a trailing comment must not silence a real one", unverified: true, src: 'git rev-parse "$ref" >/dev/null || die "no" # --verify deliberately omitted here' },
|
|
318
|
-
{ why: "a `--verify` in the die message is prose, not an argument", unverified: true, src: 'git rev-parse "$ref" >/dev/null || die "unresolved; pass --verify to fix this"' },
|
|
319
|
-
{ why: "`if ! … ; then die` on a bare name", unverified: true, src: 'if ! git rev-parse "$ref" >/dev/null; then\n die "no"\nfi' },
|
|
320
|
-
|
|
321
|
-
{ why: "`--verify` present", unverified: false, src: 'git rev-parse --verify "$ref" >/dev/null || die "no"' },
|
|
322
|
-
{ why: "a repository probe names no ref", unverified: false, src: 'git rev-parse --git-dir >/dev/null 2>&1 || die "not inside a git repository"' },
|
|
323
|
-
{ why: "`--git-path` takes a path, not a rev", unverified: false, src: 'git rev-parse --path-format=absolute --git-path logs/refs/stash >/dev/null || die "no"' },
|
|
324
|
-
// The BARE spelling is load-bearing and must stay bare. This is the only row
|
|
325
|
-
// in either table excluded solely by the `>/dev/null` clause of
|
|
326
|
-
// `isUnverifiedGuard` — written with `--verify` it would be excluded by the
|
|
327
|
-
// `--verify` clause as well, and deleting the `>/dev/null` clause would leave
|
|
328
|
-
// this file green. Measured both ways, 2026-09-03: bare, that deletion reds
|
|
329
|
-
// this test; with `--verify`, it does not.
|
|
330
|
-
{ why: "a capture is a different mechanism — excluded on shape, whatever #1146 did to the real site", unverified: false, src: 'tip=$(git rev-parse "origin/$branch") || die "no"' },
|
|
331
|
-
{ why: "a probe whose failure is the answer", unverified: false, src: 'git rev-parse "$ref" >/dev/null && die "taken"' },
|
|
332
|
-
];
|
|
333
|
-
|
|
334
|
-
test("the sweep keys on the defect, not on one spelling of it", () => {
|
|
335
|
-
for (const f of SHAPES) {
|
|
336
|
-
const hit = scan("fixture.sh", f.src).filter(isMutedGuard);
|
|
337
|
-
assert.equal(hit.length, f.muted ? 1 : 0,
|
|
338
|
-
`${f.why}: expected ${f.muted ? "a hit" : "no hit"}, got ${JSON.stringify(hit.map((g) => g.line))} from ${JSON.stringify(f.src)}`);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
test("the --verify half keys on shape, not on a list of variable names", () => {
|
|
343
|
-
for (const f of REFS) {
|
|
344
|
-
const hit = scan("fixture.sh", f.src).filter(isUnverifiedGuard);
|
|
345
|
-
assert.equal(hit.length, f.unverified ? 1 : 0,
|
|
346
|
-
`${f.why}: expected ${f.unverified ? "a hit" : "no hit"}, got ${JSON.stringify(hit.map((g) => g.line))} from ${JSON.stringify(f.src)}`);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
// ---------------------------------------------------------------------------
|
|
351
|
-
// Behaviour. The static sweep above pins the spelling; these pin what the
|
|
352
|
-
// spelling buys, per site, at the script's own boundary.
|
|
353
|
-
|
|
354
|
-
const ENV = {
|
|
355
|
-
...process.env,
|
|
356
|
-
GIT_DIR: undefined,
|
|
357
|
-
GIT_WORK_TREE: undefined,
|
|
358
|
-
GIT_AUTHOR_NAME: "t",
|
|
359
|
-
GIT_AUTHOR_EMAIL: "t@example.com",
|
|
360
|
-
GIT_COMMITTER_NAME: "t",
|
|
361
|
-
GIT_COMMITTER_EMAIL: "t@example.com",
|
|
362
|
-
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
363
|
-
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
const git = (cwd, ...args) => execFileSync("git", args, { cwd, env: ENV, encoding: "utf8" }).trim();
|
|
367
|
-
|
|
368
|
-
/** Bare origin, a clone on `main`, and a linked worktree on a pushed `feat`. */
|
|
369
|
-
function repo(t) {
|
|
370
|
-
// realpath'd: on macOS `$TMPDIR` sits under the `/var` → `/private/var`
|
|
371
|
-
// symlink and the scripts report the RESOLVED path.
|
|
372
|
-
const root = realpathSync(mkdtempSync(join(tmpdir(), "muted-guard-")));
|
|
373
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
374
|
-
const origin = join(root, "origin.git");
|
|
375
|
-
const work = join(root, "work");
|
|
376
|
-
const wt = join(root, "wt");
|
|
377
|
-
execFileSync("git", ["init", "-q", "--bare", "-b", "main", origin], { env: ENV });
|
|
378
|
-
execFileSync("git", ["clone", "-q", origin, work], { env: ENV });
|
|
379
|
-
writeFileSync(join(work, "f.txt"), "x\n");
|
|
380
|
-
git(work, "add", "f.txt");
|
|
381
|
-
git(work, "commit", "-q", "-m", "init");
|
|
382
|
-
git(work, "push", "-q", "origin", "main");
|
|
383
|
-
git(work, "worktree", "add", "-q", wt, "-b", "feat");
|
|
384
|
-
git(work, "push", "-q", "origin", "feat");
|
|
385
|
-
git(work, "fetch", "-q", "origin");
|
|
386
|
-
return { root, work, wt };
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const run = (cwd, script, args, extraEnv) =>
|
|
390
|
-
spawnSync("sh", [join(DIR, script), ...args], { cwd, env: { ...ENV, ...extraEnv }, encoding: "utf8" });
|
|
391
|
-
|
|
392
|
-
// Each site, by the caller-facing way in. `release-ticket.sh` accepts only a
|
|
393
|
-
// remote-tracking base — an earlier guard refuses any other shape — so the
|
|
394
|
-
// fixture must be `origin/…` there or the run never reaches the line under test.
|
|
395
|
-
//
|
|
396
|
-
// `remedy` is what may follow the observation, and only that. A guard may name
|
|
397
|
-
// an ACTION that is true whatever the cause; it may not guess BETWEEN causes it
|
|
398
|
-
// cannot tell apart. Measured: `git rev-parse --verify` answers
|
|
399
|
-
// `fatal: Needed a single revision` for a never-pushed branch, a stale ref,
|
|
400
|
-
// `main^99`, `refs/heads/nope` and a plain `nosuchref` alike — a constant, so
|
|
401
|
-
// git's stderr cannot pick the cause either and a cause list is always a guess.
|
|
402
|
-
const SITES = [
|
|
403
|
-
{ script: "worktree-audit.sh", args: [], env: { BASE_REF: "origin/nosuchref" }, names: "origin/nosuchref", remedy: null },
|
|
404
|
-
{ script: "reap.sh", args: [], env: { BASE_REF: "origin/nosuchref" }, names: "origin/nosuchref", remedy: null },
|
|
405
|
-
{ script: "release-ticket.sh", args: ["578", "feat", "fix"], env: { BASE_REF: "origin/nosuchref" }, names: "origin/nosuchref", remedy: null },
|
|
406
|
-
{ script: "no-undo-audit.sh", args: ["@WT@", "feat"], env: { BASE_REF: "origin/nosuchref" }, names: "origin/nosuchref", remedy: null },
|
|
407
|
-
// The sharp site: a branch that resolves locally but was never pushed. Its
|
|
408
|
-
// message used to assert `fetch it, or it was never pushed` — a two-item
|
|
409
|
-
// cause list this guard cannot distinguish between, and not even the whole
|
|
410
|
-
// set. What replaces it is an action, not a cause: one `git fetch origin` is
|
|
411
|
-
// the right next move whichever of them fired, so it stays true where the
|
|
412
|
-
// list could not. BASE_REF is left healthy so the `$base` guard above it
|
|
413
|
-
// cannot fire.
|
|
414
|
-
{
|
|
415
|
-
script: "no-undo-audit.sh", args: ["@WT@", "never-pushed"], env: {}, names: "origin/never-pushed",
|
|
416
|
-
remedy: /refs\/remotes\/origin\/never-pushed does not resolve — run 'git fetch origin' and retry/,
|
|
417
|
-
},
|
|
418
|
-
];
|
|
419
|
-
|
|
420
|
-
for (const s of SITES) {
|
|
421
|
-
test(`${s.script} (${s.names}): git's own reason reaches stderr, and the exit is unchanged`, (t) => {
|
|
422
|
-
const c = repo(t);
|
|
423
|
-
const r = run(c.work, s.script, s.args.map((a) => (a === "@WT@" ? c.wt : a)), s.env);
|
|
424
|
-
|
|
425
|
-
// Dropping `--quiet` moves the rev-parse's OWN status 1 → 128. `die` exits
|
|
426
|
-
// 2 unconditionally, so the script's vocabulary must not move with it.
|
|
427
|
-
assert.equal(r.status, 2, `refusal must stay exit 2, got ${r.status}; stderr ${JSON.stringify(r.stderr)}`);
|
|
428
|
-
assert.match(r.stderr, new RegExp(`${s.names} does not resolve`),
|
|
429
|
-
"the guard must still say what it observed");
|
|
430
|
-
assert.match(r.stderr, /fatal: Needed a single revision/,
|
|
431
|
-
"git's own diagnosis must survive to stderr — this is the whole point of the ticket");
|
|
432
|
-
if (s.remedy) {
|
|
433
|
-
assert.match(r.stderr, s.remedy, "the remedy is an action, and it must survive verbatim");
|
|
434
|
-
} else {
|
|
435
|
-
// The message states an observation and stops. Anything of the form
|
|
436
|
-
// `— …` here would be the guard guessing at a cause it cannot see.
|
|
437
|
-
assert.doesNotMatch(r.stderr, /does not resolve —/,
|
|
438
|
-
"this site has no action to offer, so it must append nothing to what it observed");
|
|
439
|
-
}
|
|
440
|
-
// No message, at any site, may guess between causes git's own constant
|
|
441
|
-
// stderr cannot tell apart. This is the clause #578 removed.
|
|
442
|
-
assert.doesNotMatch(r.stderr, /fetch it, or it was never pushed/,
|
|
443
|
-
"a cause list the guard cannot distinguish between is a guess, not information");
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
test("an unambiguous healthy guard is silent — unmuting costs that path nothing", (t) => {
|
|
448
|
-
const c = repo(t);
|
|
449
|
-
// Both invocation forms that ship: with `-C <worktree>` and without.
|
|
450
|
-
for (const args of [["rev-parse", "--verify", "origin/main"], ["-C", c.wt, "rev-parse", "--verify", "origin/feat"]]) {
|
|
451
|
-
const r = spawnSync("git", args, { cwd: c.work, env: ENV, encoding: "utf8" });
|
|
452
|
-
assert.equal(r.status, 0);
|
|
453
|
-
assert.equal(r.stderr, "", `a guard that SUCCEEDS must add nothing to stderr, got ${JSON.stringify(r.stderr)}`);
|
|
454
|
-
}
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
test("an AMBIGUOUS name is what unmuting does cost — a succeeding guard warns", (t) => {
|
|
458
|
-
// The one price of dropping `--quiet`, pinned rather than left to the word
|
|
459
|
-
// "silent" above. A refname that is both a branch and a tag resolves fine —
|
|
460
|
-
// exit 0, the audit still runs — but git now says so, and `--quiet` used to
|
|
461
|
-
// swallow that. Worth knowing: it is a warning about the OPERATOR's ref, not
|
|
462
|
-
// noise, and no guard here refuses on it.
|
|
463
|
-
const c = repo(t);
|
|
464
|
-
git(c.work, "tag", "dup", "main");
|
|
465
|
-
git(c.work, "branch", "dup", "main");
|
|
466
|
-
const r = spawnSync("git", ["rev-parse", "--verify", "dup"], { cwd: c.work, env: ENV, encoding: "utf8" });
|
|
467
|
-
assert.equal(r.status, 0, "an ambiguous name still resolves — the guard passes");
|
|
468
|
-
assert.match(r.stderr, /warning: refname 'dup' is ambiguous/,
|
|
469
|
-
"this is the cost of unmuting, and it is stated here so the next reader does not read `silent` as unconditional");
|
|
470
|
-
const quiet = spawnSync("git", ["rev-parse", "--quiet", "--verify", "dup"], { cwd: c.work, env: ENV, encoding: "utf8" });
|
|
471
|
-
assert.equal(quiet.stderr, "", "and `--quiet` is what used to suppress it — that is why this is a cost, not a coincidence");
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
test("reap.sh: the base guard sits under the fetch guard, and the order holds", (t) => {
|
|
475
|
-
// The one ordering this ticket flagged for checking rather than reasoning
|
|
476
|
-
// about. Both legs refuse at 2, so the exit alone cannot tell them apart —
|
|
477
|
-
// the MESSAGE is what the runbook reads, and each must name its own failure.
|
|
478
|
-
const c = repo(t);
|
|
479
|
-
|
|
480
|
-
const healthyFetch = run(c.work, "reap.sh", [], { BASE_REF: "origin/nosuchref" });
|
|
481
|
-
assert.equal(healthyFetch.status, 2);
|
|
482
|
-
assert.match(healthyFetch.stderr, /reap: origin\/nosuchref does not resolve/);
|
|
483
|
-
assert.doesNotMatch(healthyFetch.stderr, /fetch failed/, "the fetch succeeded — this must be the guard after it");
|
|
484
|
-
|
|
485
|
-
// Now break the fetch. The base is still unresolvable, so if the order ever
|
|
486
|
-
// inverts this leg starts reporting the base instead of the transport.
|
|
487
|
-
git(c.work, "remote", "set-url", "origin", join(c.root, "nope.git"));
|
|
488
|
-
const brokenFetch = run(c.work, "reap.sh", [], { BASE_REF: "origin/nosuchref" });
|
|
489
|
-
assert.equal(brokenFetch.status, 2);
|
|
490
|
-
assert.match(brokenFetch.stderr, /reap: fetch failed — refusing to reap on stale refs/);
|
|
491
|
-
assert.doesNotMatch(brokenFetch.stderr, /does not resolve/,
|
|
492
|
-
"a broken transport must not be reported as an unresolvable base — the fetch guard runs first");
|
|
493
|
-
});
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { test } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { between, phrase, stripHashGutter } from "./prose-pin.mjs";
|
|
6
|
-
|
|
7
|
-
// #350. The ssh-hardening comment said its options "land on top of"
|
|
8
|
-
// whatever the user's own ssh command already says. That reads as override, and
|
|
9
|
-
// the mechanism is the exact opposite: the options are appended LAST, and ssh
|
|
10
|
-
// takes the FIRST value of a repeated -o, so a user who has set ConnectTimeout
|
|
11
|
-
// or BatchMode keeps theirs and the value net_git sets is discarded. A
|
|
12
|
-
// reader trusting the old sentence believed the 10s bounded every run. Measured,
|
|
13
|
-
// OpenSSH_10.2p1: `ssh -o ConnectTimeout=45 -o ConnectTimeout=10 -G` reports
|
|
14
|
-
// connecttimeout 45, and against the accept-then-silent listener a user
|
|
15
|
-
// ConnectTimeout of 3 cut the connection at 3.0s, one of 25 at 25.0s, and the
|
|
16
|
-
// call's own 10s applied only with none set.
|
|
17
|
-
//
|
|
18
|
-
// The BEHAVIOUR is deliberate and stays — reversing the order would silently
|
|
19
|
-
// override a user's proxy or timeout config — so the whole defect lives in the
|
|
20
|
-
// prose, and prose is the only place it can be pinned.
|
|
21
|
-
//
|
|
22
|
-
// A pair, like inflight-citation-prose.test.mjs's citing-side pins: the
|
|
23
|
-
// corrected claims must be present, and the form that rotted must not come
|
|
24
|
-
// back. Neither alone holds — the positive pins survive a stray "lands on top
|
|
25
|
-
// of" spliced back in, and the negative pin survives the whole clause being
|
|
26
|
-
// deleted.
|
|
27
|
-
//
|
|
28
|
-
// THE CEILING, same as that file's: PRESENCE pins over a bounded slice. Text
|
|
29
|
-
// spliced INSIDE a pinned clause reddens them; a whole new sentence appended
|
|
30
|
-
// beside one does not. Reflow stays green by design — the words are pinned, not
|
|
31
|
-
// their layout.
|
|
32
|
-
//
|
|
33
|
-
// The negative pin is a word test, so it cannot tell the claim from a mention of
|
|
34
|
-
// it: a future sentence here recounting what the comment USED to say would
|
|
35
|
-
// redden it. Measured, and accepted — that history belongs here and on the
|
|
36
|
-
// commit, not in the script. Measured too, and deliberately not refused: "on top
|
|
37
|
-
// of" without "land" stays green, so the comment keeps the phrase for the
|
|
38
|
-
// non-precedence claims it already makes.
|
|
39
|
-
const NET = readFileSync(join(import.meta.dirname, "net.sh"), "utf8");
|
|
40
|
-
|
|
41
|
-
// Bounded at both ends, by net_git's own heading and by the first construct the
|
|
42
|
-
// comment documents. net.sh discusses ssh options in that one comment alone, but
|
|
43
|
-
// the bounds are what keep a later block elsewhere from satisfying these pins
|
|
44
|
-
// with the clause gutted.
|
|
45
|
-
const netGit = () =>
|
|
46
|
-
stripHashGutter(
|
|
47
|
-
between(
|
|
48
|
-
NET,
|
|
49
|
-
"# net_git <wdfile> <budget> <git arg>... — run one `git` network call",
|
|
50
|
-
"net_base_ssh=$(git config --get core.sshCommand",
|
|
51
|
-
"net.sh",
|
|
52
|
-
),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
test("net_git states ssh's first-wins rule for a repeated -o (#350)", () => {
|
|
56
|
-
assert.match(
|
|
57
|
-
netGit(),
|
|
58
|
-
phrase("ssh takes the FIRST value of a repeated -o"),
|
|
59
|
-
"net.sh no longer states which of two repeated -o values ssh uses, so nothing in the comment tells a reader whether the options it appends bound the run or are discarded",
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("net_git names the consequence: the user's own bound is the one that applies (#350)", () => {
|
|
64
|
-
assert.match(
|
|
65
|
-
netGit(),
|
|
66
|
-
phrase("the bound degrades to whatever bound the user asked for"),
|
|
67
|
-
"net.sh states the first-wins rule without its consequence — a reader can still believe the ConnectTimeout this probe sets is what bounds a run where the user set their own",
|
|
68
|
-
);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("net_git documents the BatchMode=no opt-out and what GIT_TERMINAL_PROMPT=0 does not cover (#350)", () => {
|
|
72
|
-
const text = netGit();
|
|
73
|
-
assert.match(
|
|
74
|
-
text,
|
|
75
|
-
phrase("`-o BatchMode=no`"),
|
|
76
|
-
"net.sh no longer documents that a user's own BatchMode=no survives, which is the setting that re-opens the prompt #92 exists to stop",
|
|
77
|
-
);
|
|
78
|
-
assert.match(
|
|
79
|
-
text,
|
|
80
|
-
phrase("GIT_TERMINAL_PROMPT=0 does not reach"),
|
|
81
|
-
"net.sh no longer says that GIT_TERMINAL_PROMPT=0 leaves ssh's own host-key and passphrase prompts alone, so a reader takes the unconditional GIT_TERMINAL_PROMPT=0 as covering them",
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test("net_git never describes its options as landing on top of the user's (#350)", () => {
|
|
86
|
-
assert.doesNotMatch(
|
|
87
|
-
netGit(),
|
|
88
|
-
/land(s|ing)?\s+on\s+top\s+of/i,
|
|
89
|
-
"the override framing is back in net_git's comment — ssh is first-wins, so options appended after the user's own are defaults the user overrides, and this phrasing states the reverse of what was measured",
|
|
90
|
-
);
|
|
91
|
-
});
|