@feigi/fleet-ctl 3.23.36 → 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,129 +0,0 @@
|
|
|
1
|
-
// The disposition record and its gate, as the prose states them to the
|
|
2
|
-
// two seats that act on it: review-and-fix.md step 2 tells the fix-applier to
|
|
3
|
-
// write `<scratch>/dispositions-<pr>.json` and what passes, and run-team's
|
|
4
|
-
// gate paragraph tells the controller when `ledger.mjs dispatch` refuses a
|
|
5
|
-
// finisher and what each refusal asks of it. The fix-applier prompt block that
|
|
6
|
-
// restates the record is a `>` block, which the dispatch-block golden fixture
|
|
7
|
-
// pins whole; these two paragraphs sit outside every `>` block, so nothing
|
|
8
|
-
// else holds them.
|
|
9
|
-
//
|
|
10
|
-
// THE CEILING: presence pins over bounded slices, each a contiguous clause —
|
|
11
|
-
// the rule and its condition in one span, so an inverted verdict (`ok` →
|
|
12
|
-
// `mismatch`), a flipped consequence (`no finisher` → `a finisher`) or a
|
|
13
|
-
// renamed file reds, where a keyword pin would not. They prove the clauses are
|
|
14
|
-
// there, not that nothing near them contradicts them. One pin crosses into
|
|
15
|
-
// code: the deferral reasons the prose lists are read against ALLOWED_DEFER,
|
|
16
|
-
// the list the check enforces, so the two cannot drift apart silently.
|
|
17
|
-
import { test } from "node:test";
|
|
18
|
-
import assert from "node:assert/strict";
|
|
19
|
-
import { readFileSync } from "node:fs";
|
|
20
|
-
import { join } from "node:path";
|
|
21
|
-
import { between, paragraph, phrase } from "./prose-pin.mjs";
|
|
22
|
-
import { ALLOWED_DEFER } from "./dispositions-check.mjs";
|
|
23
|
-
|
|
24
|
-
const REPO = join(import.meta.dirname, "..");
|
|
25
|
-
const REVIEW_AND_FIX = readFileSync(join(REPO, "commands", "review-and-fix.md"), "utf8");
|
|
26
|
-
const SKILL = readFileSync(join(REPO, "skills", "run-team", "SKILL.md"), "utf8");
|
|
27
|
-
|
|
28
|
-
// Step 2's record paragraph: one line, bounded by step 3's opener.
|
|
29
|
-
const recordStep = () =>
|
|
30
|
-
between(REVIEW_AND_FIX, "**Write every ruling to `<scratch>/dispositions-<pr>.json`", "\n3. **Run `testCmd`", "review-and-fix.md");
|
|
31
|
-
const gate = () => paragraph(SKILL, "That `dispatch` refuses a finisher", "run-team/SKILL.md");
|
|
32
|
-
|
|
33
|
-
test("step 2 names the record's file, beside the review file, and that the check judges it before any finisher", () => {
|
|
34
|
-
assert.match(recordStep(), phrase(
|
|
35
|
-
"**Write every ruling to `<scratch>/dispositions-<pr>.json`, beside the review result file — the disposition record `dispositions-check.mjs` judges against it before any finisher is dispatched.**",
|
|
36
|
-
));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("step 2 reads scope off the diff before the declared scope", () => {
|
|
40
|
-
assert.match(recordStep(), phrase(
|
|
41
|
-
"a finding with no `line`, or on a line `git diff` touches from the PR's merge-base with `origin/main` to the review's `head`, is in scope whatever `scope` says, and only otherwise does the declared one stand.",
|
|
42
|
-
));
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test("step 2's deferral reasons are exactly the ones the check accepts, and anything else refuses the finisher", () => {
|
|
46
|
-
const s = recordStep();
|
|
47
|
-
const listed = /An in-scope `survived` finding deferred passes only with `reason` `([^`]+)`, `([^`]+)`, `([^`]+)` or `([^`]+)`\./.exec(s);
|
|
48
|
-
assert.ok(listed, "step 2 no longer lists the in-scope deferral reasons in one sentence — update this test");
|
|
49
|
-
assert.deepEqual(listed.slice(1), [...ALLOWED_DEFER]);
|
|
50
|
-
assert.match(s, phrase(
|
|
51
|
-
"Any other reason, none, or a `survived` or `unverified` finding with no entry is a mismatch: the script exits 1 naming each violating entry's bucket, index and rule, and `ledger.mjs dispatch` refuses the PR's finisher.",
|
|
52
|
-
));
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test("step 2 requires a remedy file absent from the PR's diff for remedy-outside-diff, and refuses none or every one inside it", () => {
|
|
56
|
-
assert.match(recordStep(), phrase(
|
|
57
|
-
"`remedy-outside-diff` — the remedy would edit a file the PR's diff does not touch — also needs `remedyFiles` to name at least one file absent from `git diff` from that merge-base to the review's `head`: none named, or every one in that diff, is a mismatch.",
|
|
58
|
-
));
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test("the gate refuses a finisher unless the verdict answering the latest review's head is ok", () => {
|
|
62
|
-
const s = gate();
|
|
63
|
-
assert.match(s, phrase(
|
|
64
|
-
"That `dispatch` refuses a finisher — exit 2, nothing written — on a PR whose latest `reviewed=` counts a survived or unverified finding, unless the dispositions verdict answering that review's head is `ok`**",
|
|
65
|
-
));
|
|
66
|
-
assert.match(s, phrase("A PR whose latest review counts `0/<n>/0` is not gated."));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test("the gate says what each refusal asks of the controller", () => {
|
|
70
|
-
const s = gate();
|
|
71
|
-
assert.match(s, phrase(
|
|
72
|
-
"`dispositions unchecked` — no verdict answers that head: run `dispositions-check.mjs` for the fix-applier that answered the review",
|
|
73
|
-
));
|
|
74
|
-
assert.match(s, phrase(
|
|
75
|
-
"`dispositions mismatch` — no finisher: the tick prints `DISPATCH fix-pr PR#<M>` for it, and the next-suffix fix-applier answers it",
|
|
76
|
-
));
|
|
77
|
-
assert.match(s, phrase(
|
|
78
|
-
"`dispositions escalate` — no finisher, no retry and no further fix-applier: either a `critical` or `important` finding was deferred `remedy-outside-diff`, or a second mismatch was drawn on one review, and only a human can rule on either.",
|
|
79
|
-
));
|
|
80
|
-
assert.match(s, phrase(
|
|
81
|
-
"Post the check's output, which names each escalated finding or violating entry, with `gh pr comment <M>`, and flag the PR for a human; re-running the check reprints it. Dispatch no fix-applier and no finisher for that review's head",
|
|
82
|
-
));
|
|
83
|
-
assert.match(s, phrase(
|
|
84
|
-
"it refuses too while a fix-applier on the PR is still live, verdict or not** — `fix-pr-<M>[-x] still live`: settle it, run the check for it, then dispatch again.",
|
|
85
|
-
));
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("a mismatch is retried once by the next suffix, whose prompt carries the violation list, and a second failure escalates", () => {
|
|
89
|
-
const s = paragraph(SKILL, "`DISPATCH fix-pr PR#<M>` on a dispositions mismatch", "run-team/SKILL.md", { emphasisTolerant: true });
|
|
90
|
-
assert.match(s, phrase("is one automatic retry, a review fix-applier named the next suffix (`fix-pr-<M>-b`)"));
|
|
91
|
-
assert.match(s, phrase(
|
|
92
|
-
"the review file `<scratch>/review-<M>.json`, the disposition record `<scratch>/dispositions-<M>.json` it rewrites, and the check's violation list **verbatim**",
|
|
93
|
-
));
|
|
94
|
-
assert.match(s, phrase(
|
|
95
|
-
"A second failure on the same review is written as `dispositions-escalate=fix-pr-<M>-b:<head>` in place of a mismatch: the tick prints no `DISPATCH fix-pr` for it, `dispatch` refuses the finisher naming `dispositions escalate`",
|
|
96
|
-
));
|
|
97
|
-
assert.match(s, phrase("A new review of the PR counts again from none."));
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test("a reversed refutation reaches the ledger from the disposition record", () => {
|
|
101
|
-
assert.match(paragraph(SKILL, "`refuted` comes back deliberately as well", "run-team/SKILL.md"), phrase(
|
|
102
|
-
"The fix-applier may reverse one; it records each reversal as a `refuted` entry in its disposition record, the evidence in `reason`, and you copy those entries to the ledger's `ruled` line",
|
|
103
|
-
));
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
// Step 6's label conditions: the check over the member's own record is the
|
|
107
|
-
// fourth, so a standalone run — no controller, no ledger — holds its own label.
|
|
108
|
-
const labelStep = () => paragraph(REVIEW_AND_FIX, "6. Diff-check green (run-bound", "review-and-fix.md");
|
|
109
|
-
|
|
110
|
-
test("step 6 makes the dispositions check over the member's own record a label condition", () => {
|
|
111
|
-
assert.match(labelStep(), phrase(
|
|
112
|
-
"**and** `dispositions-check.mjs --member fix-pr-<pr> --scratch <scratch>` run over your own record exiting 0",
|
|
113
|
-
));
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test("step 6 halts a non-zero dispositions exit before the label and has the member report its violations", () => {
|
|
117
|
-
assert.match(labelStep(), phrase(
|
|
118
|
-
"A non-zero dispositions exit halts you before the label, and you report the violations it printed.",
|
|
119
|
-
));
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test("step 6 has a standalone member pass --no-ledger: no token is written and the exit status is the verdict", () => {
|
|
123
|
-
assert.match(labelStep(), phrase(
|
|
124
|
-
"standalone you pass `--no-ledger`, so it writes no token and the exit status is the verdict",
|
|
125
|
-
));
|
|
126
|
-
assert.match(labelStep(), phrase(
|
|
127
|
-
"without the flag it exits 2 for a ledger with no row for you",
|
|
128
|
-
));
|
|
129
|
-
});
|
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
// Regression gate for drop-merged-label.sh, the merge-triggered third step in
|
|
2
|
-
// the claim lifecycle (#170) — neither CONTEXT.md's Release (a claim that
|
|
3
|
-
// never became a PR) nor its Reap (branches and worktrees): claim-ticket.sh
|
|
4
|
-
// adds the label, release-ticket.sh drops it on a bail, this drops it on a
|
|
5
|
-
// merge.
|
|
6
|
-
//
|
|
7
|
-
// Zero deps: `node --test plugin/scripts/drop-merged-label.test.mjs`.
|
|
8
|
-
// No git repo needed — the script never touches git, only `gh`, so `gh` is the
|
|
9
|
-
// only thing stubbed, on PATH.
|
|
10
|
-
//
|
|
11
|
-
// Each precondition gets a case that proves it blocks ON ITS OWN, same
|
|
12
|
-
// discipline as release-ticket.test.mjs: deleting a check must fail the case
|
|
13
|
-
// named after it, not merely turn the suite red somewhere.
|
|
14
|
-
|
|
15
|
-
import { test } from "node:test";
|
|
16
|
-
import assert from "node:assert/strict";
|
|
17
|
-
import { readFileSync, mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
18
|
-
import { spawnSync, execFileSync } from "node:child_process";
|
|
19
|
-
import { tmpdir } from "node:os";
|
|
20
|
-
import { join } from "node:path";
|
|
21
|
-
import { fileURLToPath } from "node:url";
|
|
22
|
-
import { writeExecStub } from "./exec-stub.mjs";
|
|
23
|
-
|
|
24
|
-
const SCRIPT = fileURLToPath(new URL("./drop-merged-label.sh", import.meta.url));
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* A `gh` stub on PATH answering the four calls this script makes, tuned per
|
|
28
|
-
* test through env vars. Returns a call log and an env() builder, same shape
|
|
29
|
-
* as release-ticket.test.mjs's fixture.
|
|
30
|
-
*/
|
|
31
|
-
function stub(t) {
|
|
32
|
-
const root = mktemp(t);
|
|
33
|
-
const bin = join(root, "bin");
|
|
34
|
-
mkdirSync(bin);
|
|
35
|
-
const log = join(root, "gh.log");
|
|
36
|
-
writeFileSync(log, "");
|
|
37
|
-
writeExecStub(
|
|
38
|
-
join(bin, "gh"),
|
|
39
|
-
`#!/bin/sh
|
|
40
|
-
printf '%s\\n' "$*" >> "${log}"
|
|
41
|
-
case "$1 $2" in
|
|
42
|
-
"pr view")
|
|
43
|
-
pr=\$3
|
|
44
|
-
case "$*" in
|
|
45
|
-
*"--json state --jq .state")
|
|
46
|
-
[ "\${PR_STATE_FAIL:-0}" = 0 ] || { echo "gh: simulated failure" >&2; exit 1; }
|
|
47
|
-
echo "\${PR_STATE:-MERGED}"
|
|
48
|
-
;;
|
|
49
|
-
*"--json closingIssuesReferences --jq"*)
|
|
50
|
-
[ "\${CLOSES_FAIL:-0}" = 0 ] || { echo "gh: simulated failure" >&2; exit 1; }
|
|
51
|
-
[ -z "\${CLOSES:-}" ] || printf '%s\\n' \${CLOSES}
|
|
52
|
-
;;
|
|
53
|
-
*"--json commits --jq"*)
|
|
54
|
-
[ "\${COMMITS_FAIL:-0}" = 0 ] || { echo "gh: simulated failure" >&2; exit 1; }
|
|
55
|
-
# Quoted, unlike CLOSES above: commit text carries real spaces
|
|
56
|
-
# ("Closes #1512") that unquoted word-splitting would scatter across
|
|
57
|
-
# separate printf lines and break the keyword+number adjacency the
|
|
58
|
-
# script's own scan depends on.
|
|
59
|
-
[ -z "\${COMMITS:-}" ] || printf '%s\\n' "\${COMMITS}"
|
|
60
|
-
;;
|
|
61
|
-
*) echo "gh: unstubbed pr view call: $*" >&2; exit 1 ;;
|
|
62
|
-
esac
|
|
63
|
-
;;
|
|
64
|
-
"issue view")
|
|
65
|
-
n=\$3
|
|
66
|
-
case ",\${ISSUE_VIEW_FAIL:-}," in *",\$n,"*) echo "gh: simulated failure" >&2; exit 1;; esac
|
|
67
|
-
eval "labels=\\\${LABELS_\$n:-}"
|
|
68
|
-
[ -z "\$labels" ] || printf '%s\\n' \$labels
|
|
69
|
-
;;
|
|
70
|
-
"issue edit")
|
|
71
|
-
n=\$3
|
|
72
|
-
case ",\${EDIT_FAIL:-}," in *",\$n,"*) echo "gh: simulated failure" >&2; exit 1;; esac
|
|
73
|
-
;;
|
|
74
|
-
*) echo "gh: unstubbed call: $*" >&2; exit 1 ;;
|
|
75
|
-
esac
|
|
76
|
-
exit 0
|
|
77
|
-
`,
|
|
78
|
-
);
|
|
79
|
-
return {
|
|
80
|
-
log,
|
|
81
|
-
calls: () => readFileSync(log, "utf8").trim().split("\n").filter(Boolean),
|
|
82
|
-
env: (extra = {}) => ({ ...process.env, PATH: `${bin}:${process.env.PATH}`, ...extra }),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function mktemp(t) {
|
|
87
|
-
const root = mkdtempSync(join(tmpdir(), "drop-merged-label-"));
|
|
88
|
-
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
89
|
-
return root;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function run(pr, { apply = false, env = {} } = {}) {
|
|
93
|
-
const argv = apply ? [String(pr), "--apply"] : [String(pr)];
|
|
94
|
-
const res = spawnSync("sh", [SCRIPT, ...argv], { env, encoding: "utf8" });
|
|
95
|
-
return {
|
|
96
|
-
code: res.status,
|
|
97
|
-
json: res.stdout.trim() ? JSON.parse(res.stdout) : null,
|
|
98
|
-
stderr: res.stderr,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
test("usage: rejects a non-numeric PR", (t) => {
|
|
103
|
-
const s = stub(t);
|
|
104
|
-
const { code, stderr } = run("abc", { env: s.env() });
|
|
105
|
-
assert.equal(code, 2);
|
|
106
|
-
assert.match(stderr, /pr must be a number/);
|
|
107
|
-
assert.deepEqual(s.calls(), [], "must refuse before calling gh at all");
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test("usage: rejects a zero-padded PR number", (t) => {
|
|
111
|
-
// The same defect #121 names for `"issue":%s`, in this script's `"pr":%s`
|
|
112
|
-
// slot: all-digits is not a JSON number, so `007` cleared the guard and the
|
|
113
|
-
// payload emitted `{"pr":007,…}` — unparseable at exit 0. Refused before gh
|
|
114
|
-
// is reached, like every other usage error here. Two widths, because one does
|
|
115
|
-
// not pin the guard: `0?*` narrowed to `0??*` still refuses `007` and
|
|
116
|
-
// re-admits `01`, which is the same bug back.
|
|
117
|
-
const s = stub(t);
|
|
118
|
-
for (const padded of ["007", "01"]) {
|
|
119
|
-
const { code, stderr } = run(padded, { env: s.env() });
|
|
120
|
-
assert.equal(code, 2, padded);
|
|
121
|
-
assert.match(stderr, /pr must be a number/);
|
|
122
|
-
}
|
|
123
|
-
assert.deepEqual(s.calls(), [], "must refuse before calling gh at all");
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("usage: a bare 0 clears the numeric guard", (t) => {
|
|
127
|
-
// `0?*`, not `0*`: #121 lists `sh inflight.sh 0 -> parses` among its PASSING
|
|
128
|
-
// cases, beside `42`. A bare `0` is a valid RFC 8259 number and `$((0))` is
|
|
129
|
-
// `0`, so neither hazard the guard exists to close applies to it. Widening
|
|
130
|
-
// the arm would refuse a value the ticket's own worked example shows working.
|
|
131
|
-
const s = stub(t);
|
|
132
|
-
const { code, stderr } = run("0", { env: s.env() });
|
|
133
|
-
assert.doesNotMatch(stderr, /pr must be a number/);
|
|
134
|
-
assert.equal(code, 0, "0 clears the guard and runs to completion");
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test("usage: rejects an unknown second argument", (t) => {
|
|
138
|
-
const s = stub(t);
|
|
139
|
-
const { code, stderr } = run(9, { apply: false, env: s.env() });
|
|
140
|
-
const res = spawnSync("sh", [SCRIPT, "9", "--wat"], { env: s.env(), encoding: "utf8" });
|
|
141
|
-
assert.equal(res.status, 2);
|
|
142
|
-
assert.match(res.stderr, /unknown argument/);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test("a PR whose state query fails halts before anything else", (t) => {
|
|
146
|
-
const s = stub(t);
|
|
147
|
-
const { code, stderr } = run(9, { env: s.env({ PR_STATE_FAIL: "1" }) });
|
|
148
|
-
assert.equal(code, 2);
|
|
149
|
-
assert.match(stderr, /cannot tell whether it merged/);
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
test("a PR that is not merged is refused, not silently skipped", (t) => {
|
|
153
|
-
const s = stub(t);
|
|
154
|
-
const { code, stderr } = run(9, { env: s.env({ PR_STATE: "CLOSED" }) });
|
|
155
|
-
assert.equal(code, 2);
|
|
156
|
-
assert.match(stderr, /not merged \(state=CLOSED\)/);
|
|
157
|
-
// Never reaches the closingIssuesReferences call — a closed-not-merged PR
|
|
158
|
-
// is nothing this script may touch, so nothing past state should ever run.
|
|
159
|
-
assert.ok(!s.calls().some((c) => c.includes("closingIssuesReferences")));
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test("closingIssuesReferences query failing after a confirmed merge still halts", (t) => {
|
|
163
|
-
const s = stub(t);
|
|
164
|
-
const { code, stderr } = run(9, { env: s.env({ CLOSES_FAIL: "1" }) });
|
|
165
|
-
assert.equal(code, 2);
|
|
166
|
-
assert.match(stderr, /cannot read which issues it closes/);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
test("a merged PR that closes nothing is a clean no-op", (t) => {
|
|
170
|
-
const s = stub(t);
|
|
171
|
-
const { code, json } = run(9, { apply: true, env: s.env({ CLOSES: "" }) });
|
|
172
|
-
assert.equal(code, 0);
|
|
173
|
-
assert.deepEqual(json, { pr: 9, merged: true, issues: [], applied: true, failed: [] });
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test("dry run reports what it would drop and touches nothing", (t) => {
|
|
177
|
-
const s = stub(t);
|
|
178
|
-
const { code, json } = run(9, { apply: false, env: s.env({ CLOSES: "41", LABELS_41: "in-progress ready-for-agent" }) });
|
|
179
|
-
assert.equal(code, 0);
|
|
180
|
-
assert.deepEqual(json.issues, [{ issue: 41, hadLabel: true, removed: false }]);
|
|
181
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue edit")), "dry run must never call issue edit");
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
test("--apply drops in-progress from a merged PR's closed issue", (t) => {
|
|
185
|
-
const s = stub(t);
|
|
186
|
-
const { code, json } = run(9, { apply: true, env: s.env({ CLOSES: "41", LABELS_41: "in-progress ready-for-agent" }) });
|
|
187
|
-
assert.equal(code, 0);
|
|
188
|
-
assert.deepEqual(json.issues, [{ issue: 41, hadLabel: true, removed: true }]);
|
|
189
|
-
assert.ok(s.calls().includes("issue edit 41 --remove-label in-progress"));
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
test("an issue that already lost the label is reported clear, not re-edited", (t) => {
|
|
193
|
-
const s = stub(t);
|
|
194
|
-
const { code, json } = run(9, { apply: true, env: s.env({ CLOSES: "41", LABELS_41: "ready-for-agent" }) });
|
|
195
|
-
assert.equal(code, 0);
|
|
196
|
-
assert.deepEqual(json.issues, [{ issue: 41, hadLabel: false, removed: false }]);
|
|
197
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue edit")));
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test("a failed label read is reported, never swallowed", (t) => {
|
|
201
|
-
const s = stub(t);
|
|
202
|
-
const { code, json } = run(9, {
|
|
203
|
-
apply: true,
|
|
204
|
-
env: s.env({ CLOSES: "41", ISSUE_VIEW_FAIL: "41" }),
|
|
205
|
-
});
|
|
206
|
-
assert.equal(code, 1);
|
|
207
|
-
assert.deepEqual(json.failed, [41]);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// #1543. Same defect class PR #1519 fixed in reap.sh's grep_probe: `grep -q`
|
|
211
|
-
// has THREE outcomes and the bare `if … grep -qx …; then had=true; else
|
|
212
|
-
// had=false; fi` this script used to run had room for only two — rc 0
|
|
213
|
-
// matched, rc 1 none did, rc 2+ the scan itself broke — so grep's OWN failure
|
|
214
|
-
// used to fold into `had=false`, reading exactly like the "already clear"
|
|
215
|
-
// case two tests up and letting a merged ticket keep the label with nothing
|
|
216
|
-
// reported.
|
|
217
|
-
// Generalized over a `trigger` substring so the same shim can target either
|
|
218
|
-
// this script's label scan (`-qx`) or its #1617 commit-message scan
|
|
219
|
-
// (`-Eio`) in isolation — passthrough to the real `grep` for every other
|
|
220
|
-
// invocation, so only the targeted call site ever sees the simulated break.
|
|
221
|
-
function grepFailShim(t, trigger) {
|
|
222
|
-
const bin = mkdtempSync(join(tmpdir(), "drop-merged-label-grep-shim-"));
|
|
223
|
-
t.after(() => rmSync(bin, { recursive: true, force: true }));
|
|
224
|
-
const realGrep = execFileSync("/bin/sh", ["-c", "command -v grep"], { encoding: "utf8" }).trim();
|
|
225
|
-
writeExecStub(
|
|
226
|
-
join(bin, "grep"),
|
|
227
|
-
`#!/bin/sh\ncase "$*" in\n *${trigger}*) echo "grep: illegal byte sequence" >&2; exit 2 ;;\nesac\nexec ${realGrep} "$@"\n`,
|
|
228
|
-
);
|
|
229
|
-
return bin;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
test("a grep scan failure over an issue's labels is reported failed, never read as already clear", (t) => {
|
|
233
|
-
const s = stub(t);
|
|
234
|
-
const bin = grepFailShim(t, "-qx");
|
|
235
|
-
const base = s.env({ CLOSES: "41", LABELS_41: "in-progress" });
|
|
236
|
-
const { code, json } = run(9, { apply: true, env: { ...base, PATH: `${bin}:${base.PATH}` } });
|
|
237
|
-
assert.equal(code, 1, "a swallowed scan failure would read as success (exit 0)");
|
|
238
|
-
assert.deepEqual(json.issues, [{ issue: 41, hadLabel: null, removed: false }],
|
|
239
|
-
"hadLabel must be null (unknown), not false — false is the reading a completed, genuinely-empty scan earns");
|
|
240
|
-
assert.deepEqual(json.failed, [41]);
|
|
241
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue edit")),
|
|
242
|
-
"an unscanned label must not be removed on a guess either");
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
test("a failed removal is reported loudly, not swallowed — the acceptance criterion", (t) => {
|
|
246
|
-
const s = stub(t);
|
|
247
|
-
const { code, json, stderr } = run(9, {
|
|
248
|
-
apply: true,
|
|
249
|
-
env: s.env({ CLOSES: "41", LABELS_41: "in-progress", EDIT_FAIL: "41" }),
|
|
250
|
-
});
|
|
251
|
-
assert.equal(code, 1, "a swallowed failure would read as success (exit 0)");
|
|
252
|
-
assert.deepEqual(json.issues, [{ issue: 41, hadLabel: true, removed: false }]);
|
|
253
|
-
assert.deepEqual(json.failed, [41]);
|
|
254
|
-
assert.match(stderr, /FAILED to drop in-progress/);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
test("one failure among several issues does not stop the rest from being processed", (t) => {
|
|
258
|
-
const s = stub(t);
|
|
259
|
-
const { code, json } = run(9, {
|
|
260
|
-
apply: true,
|
|
261
|
-
env: s.env({
|
|
262
|
-
CLOSES: "41\n42",
|
|
263
|
-
LABELS_41: "in-progress",
|
|
264
|
-
LABELS_42: "in-progress",
|
|
265
|
-
EDIT_FAIL: "41",
|
|
266
|
-
}),
|
|
267
|
-
});
|
|
268
|
-
assert.equal(code, 1);
|
|
269
|
-
assert.deepEqual(json.issues, [
|
|
270
|
-
{ issue: 41, hadLabel: true, removed: false },
|
|
271
|
-
{ issue: 42, hadLabel: true, removed: true },
|
|
272
|
-
]);
|
|
273
|
-
assert.deepEqual(json.failed, [41]);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// The acceptance criterion is "reopening a previously-merged ticket makes it a
|
|
277
|
-
// candidate again" — verified against the real consumer, not against this
|
|
278
|
-
// file's idea of one. candidates.mjs excludes on the literal string
|
|
279
|
-
// `-label:in-progress`; this proves this script issues the exact `gh issue
|
|
280
|
-
// edit --remove-label in-progress` call that clears the one flag that clause
|
|
281
|
-
// keys on, so a reopened issue this script has touched no longer matches it.
|
|
282
|
-
test("the label this script drops is the exact one candidates.mjs excludes on", (t) => {
|
|
283
|
-
const candidates = readFileSync(
|
|
284
|
-
fileURLToPath(new URL("./candidates.mjs", import.meta.url)),
|
|
285
|
-
"utf8",
|
|
286
|
-
);
|
|
287
|
-
assert.match(candidates, /-label:in-progress/, "candidates.mjs moved its exclusion — update this test");
|
|
288
|
-
|
|
289
|
-
const s = stub(t);
|
|
290
|
-
const { code } = run(9, { apply: true, env: s.env({ CLOSES: "41", LABELS_41: "in-progress" }) });
|
|
291
|
-
assert.equal(code, 0);
|
|
292
|
-
assert.ok(s.calls().includes("issue edit 41 --remove-label in-progress"));
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
// #1617. `closingIssuesReferences` reflects `Closes #N` syntax only when it
|
|
296
|
-
// lives in the PR's own title/body. PR #1614 (ticket #1512) had an EMPTY PR
|
|
297
|
-
// body but a commit message (`52a68b4`) carrying `Closes #1512` — GitHub's
|
|
298
|
-
// real merge-time closer honored it and closed #1512, but this script read
|
|
299
|
-
// back an empty `closingIssuesReferences` array and left `in-progress`
|
|
300
|
-
// stuck. This reproduces that exact shape.
|
|
301
|
-
test("PR #1614's exact shape: an empty closingIssuesReferences with a commit-message-only Closes #N still drops the label", (t) => {
|
|
302
|
-
const s = stub(t);
|
|
303
|
-
const { code, json } = run(1614, {
|
|
304
|
-
apply: true,
|
|
305
|
-
env: s.env({
|
|
306
|
-
CLOSES: "",
|
|
307
|
-
COMMITS: "fix(run-merge-bot): verify the fallback worktree against the branch ref\n\nCloses #1512",
|
|
308
|
-
LABELS_1512: "in-progress ready-for-agent",
|
|
309
|
-
}),
|
|
310
|
-
});
|
|
311
|
-
assert.equal(code, 0);
|
|
312
|
-
assert.deepEqual(json.issues, [{ issue: 1512, hadLabel: true, removed: true }]);
|
|
313
|
-
assert.ok(s.calls().includes("issue edit 1512 --remove-label in-progress"));
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
test("commit-message scan recognizes every close/fix/resolve keyword form, case-insensitively", (t) => {
|
|
317
|
-
const s = stub(t);
|
|
318
|
-
const { code, json } = run(9, {
|
|
319
|
-
apply: true,
|
|
320
|
-
env: s.env({
|
|
321
|
-
CLOSES: "",
|
|
322
|
-
COMMITS: "Fixes #10\n\nsome body text\n\nresolved #20\n\nRESOLVES #30",
|
|
323
|
-
LABELS_10: "in-progress",
|
|
324
|
-
LABELS_20: "in-progress",
|
|
325
|
-
LABELS_30: "in-progress",
|
|
326
|
-
}),
|
|
327
|
-
});
|
|
328
|
-
assert.equal(code, 0);
|
|
329
|
-
assert.deepEqual(json.issues, [
|
|
330
|
-
{ issue: 10, hadLabel: true, removed: true },
|
|
331
|
-
{ issue: 20, hadLabel: true, removed: true },
|
|
332
|
-
{ issue: 30, hadLabel: true, removed: true },
|
|
333
|
-
]);
|
|
334
|
-
});
|
|
335
|
-
|
|
336
|
-
test("a commit message merely mentioning an issue without a close keyword does not close it", (t) => {
|
|
337
|
-
const s = stub(t);
|
|
338
|
-
const { code, json } = run(9, {
|
|
339
|
-
apply: true,
|
|
340
|
-
env: s.env({ CLOSES: "", COMMITS: "Related to #99, see also #100 for background" }),
|
|
341
|
-
});
|
|
342
|
-
assert.equal(code, 0);
|
|
343
|
-
assert.deepEqual(json, { pr: 9, merged: true, issues: [], applied: true, failed: [] });
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
test("closingIssuesReferences and a commit-message reference union, without processing a shared issue twice", (t) => {
|
|
347
|
-
const s = stub(t);
|
|
348
|
-
const { code, json } = run(9, {
|
|
349
|
-
apply: true,
|
|
350
|
-
env: s.env({
|
|
351
|
-
CLOSES: "41",
|
|
352
|
-
COMMITS: "Closes #41\n\nCloses #55",
|
|
353
|
-
LABELS_41: "in-progress",
|
|
354
|
-
LABELS_55: "in-progress",
|
|
355
|
-
}),
|
|
356
|
-
});
|
|
357
|
-
assert.equal(code, 0);
|
|
358
|
-
assert.deepEqual(json.issues, [
|
|
359
|
-
{ issue: 41, hadLabel: true, removed: true },
|
|
360
|
-
{ issue: 55, hadLabel: true, removed: true },
|
|
361
|
-
]);
|
|
362
|
-
const viewsOf41 = s.calls().filter((c) => c === "issue view 41 --json labels --jq .labels[].name");
|
|
363
|
-
assert.equal(viewsOf41.length, 1, "an issue named by both signals must be looked up once, not once per signal");
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
test("the commit-message query failing after a confirmed merge still halts", (t) => {
|
|
367
|
-
const s = stub(t);
|
|
368
|
-
const { code, stderr } = run(9, { env: s.env({ CLOSES: "", COMMITS_FAIL: "1" }) });
|
|
369
|
-
assert.equal(code, 2);
|
|
370
|
-
assert.match(stderr, /cannot scan its commit messages for issue closes/);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
// Same discipline as #1543's label-scan fix, applied to the new commit scan:
|
|
374
|
-
// rc 1 (no keyword anywhere) is zero commit-closed issues, but rc 2+ (the
|
|
375
|
-
// scan itself broke) must halt loudly, never silently read as "commits close
|
|
376
|
-
// nothing" — a swallowed break here would look exactly like the previous
|
|
377
|
-
// test's `Related to #99` case even though the scan never actually ran.
|
|
378
|
-
test("a grep scan failure over commit messages halts loudly, never read as commits closing nothing", (t) => {
|
|
379
|
-
const s = stub(t);
|
|
380
|
-
const bin = grepFailShim(t, "-Eio");
|
|
381
|
-
const base = s.env({ CLOSES: "", COMMITS: "Closes #1512" });
|
|
382
|
-
const { code, stderr } = run(9, { apply: true, env: { ...base, PATH: `${bin}:${base.PATH}` } });
|
|
383
|
-
assert.equal(code, 2, "a swallowed scan failure would read as a clean no-op (exit 0)");
|
|
384
|
-
assert.match(stderr, /could not scan PR #9's commit messages for issue closes \(grep exited 2\)/);
|
|
385
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue view") || c.startsWith("issue edit")),
|
|
386
|
-
"an unscanned commit history must never be treated as having resolved to zero issues");
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// The digit-extraction step that turns a matched commit line into a bare
|
|
390
|
-
// issue number is guarded the same way, so a broken extraction halts with
|
|
391
|
-
// this script's own branded die() message instead of raw, unbranded grep
|
|
392
|
-
// stderr and no diagnosis of which step failed.
|
|
393
|
-
test("a grep scan failure extracting issue numbers from matched commit text halts loudly with a branded die() message", (t) => {
|
|
394
|
-
const s = stub(t);
|
|
395
|
-
const bin = grepFailShim(t, "-Eo");
|
|
396
|
-
const base = s.env({ CLOSES: "", COMMITS: "Closes #1512" });
|
|
397
|
-
const { code, stderr } = run(9, { apply: true, env: { ...base, PATH: `${bin}:${base.PATH}` } });
|
|
398
|
-
assert.equal(code, 2, "a swallowed extraction failure must not read as success (exit 0)");
|
|
399
|
-
assert.match(stderr, /drop-merged-label: could not extract issue numbers from PR #9's matched commit text \(grep exited 2\)/);
|
|
400
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue view") || c.startsWith("issue edit")),
|
|
401
|
-
"an unextracted commit match must never be treated as resolving to zero issues");
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
// #1543's own discipline, generalized to the LAST step of the scan: unioning
|
|
405
|
-
// `$issues` and `$commit_issues` used to run a bare `grep | sort`, and
|
|
406
|
-
// command substitution reports only the LAST pipe stage's exit status —
|
|
407
|
-
// `sort`'s own rc 0 silently masked a grep 2+ break, reading exactly like
|
|
408
|
-
// the PR closing zero issues even though the union scan itself never ran.
|
|
409
|
-
// A keyword-free COMMITS means the earlier commit-message scan (its own,
|
|
410
|
-
// already-guarded grep) legitimately returns rc 1 and skips straight past
|
|
411
|
-
// the digit-extraction grep, so this is the ONLY grep call the union step
|
|
412
|
-
// reaches — isolating the exact call this fix guards.
|
|
413
|
-
test("a grep scan failure in the final issue-number union halts loudly, never silently unions to zero issues", (t) => {
|
|
414
|
-
const s = stub(t);
|
|
415
|
-
const bin = grepFailShim(t, "-Eo");
|
|
416
|
-
const base = s.env({ CLOSES: "41", COMMITS: "Related to #99, see also #100 for background" });
|
|
417
|
-
const { code, stderr } = run(9, { apply: true, env: { ...base, PATH: `${bin}:${base.PATH}` } });
|
|
418
|
-
assert.equal(code, 2, "a swallowed union failure would read as the PR closing zero issues (exit 0)");
|
|
419
|
-
assert.match(stderr, /could not union PR #9's closing issues \(grep exited 2\)/);
|
|
420
|
-
assert.ok(!s.calls().some((c) => c.startsWith("issue view") || c.startsWith("issue edit")),
|
|
421
|
-
"issue #41 already carrying in-progress must never be silently skipped because the union step broke");
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
// The keyword regex used to have no boundary before it, so it matched
|
|
425
|
-
// "fix"/"close(d)" as a bare SUBSTRING of an unrelated word. Each of these
|
|
426
|
-
// three commit lines contains one of the keyword strings glued to a longer
|
|
427
|
-
// word with no non-word character in front of it, so none of them may close
|
|
428
|
-
// anything.
|
|
429
|
-
test("a keyword regex requires a word boundary — 'bugfix', 'prefix', and 'unclosed' as substrings do not trigger a close", (t) => {
|
|
430
|
-
const s = stub(t);
|
|
431
|
-
const { code, json } = run(9, {
|
|
432
|
-
apply: true,
|
|
433
|
-
env: s.env({
|
|
434
|
-
CLOSES: "",
|
|
435
|
-
COMMITS: "chore: bugfix #77 rolled forward\n\nrefactor: prefix #88 handling\n\nnote: left unclosed #99 for later",
|
|
436
|
-
}),
|
|
437
|
-
});
|
|
438
|
-
assert.equal(code, 0);
|
|
439
|
-
assert.deepEqual(json, { pr: 9, merged: true, issues: [], applied: true, failed: [] });
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
// The boundary fix must not regress a real keyword that follows punctuation
|
|
443
|
-
// or a space mid-line (not just one that opens the line) — the alternation's
|
|
444
|
-
// `[^[:alnum:]_]` branch, not only its `^` branch.
|
|
445
|
-
test("a real close keyword preceded by punctuation, not just line-start, still closes", (t) => {
|
|
446
|
-
const s = stub(t);
|
|
447
|
-
const { code, json } = run(9, {
|
|
448
|
-
apply: true,
|
|
449
|
-
env: s.env({ CLOSES: "", COMMITS: "See other work; closes #77 too", LABELS_77: "in-progress" }),
|
|
450
|
-
});
|
|
451
|
-
assert.equal(code, 0);
|
|
452
|
-
assert.deepEqual(json.issues, [{ issue: 77, hadLabel: true, removed: true }]);
|
|
453
|
-
});
|
|
454
|
-
|
|
455
|
-
// #121's defect class: a bare zero-padded digit string flowed unnormalized
|
|
456
|
-
// into the JSON payload as an illegal leading-zero JSON number. Verified by
|
|
457
|
-
// actually parsing the script's stdout as JSON (run()'s own JSON.parse),
|
|
458
|
-
// exactly like this file's other JSON-payload-validity assertions.
|
|
459
|
-
test("a zero-padded commit-message issue number normalizes to a valid JSON integer", (t) => {
|
|
460
|
-
const s = stub(t);
|
|
461
|
-
const { code, json } = run(9, {
|
|
462
|
-
apply: true,
|
|
463
|
-
env: s.env({ CLOSES: "", COMMITS: "Closes #007", LABELS_7: "in-progress" }),
|
|
464
|
-
});
|
|
465
|
-
assert.equal(code, 0);
|
|
466
|
-
assert.deepEqual(json.issues, [{ issue: 7, hadLabel: true, removed: true }]);
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
test("a zero-padded commit-message reference dedupes against the same issue named by closingIssuesReferences", (t) => {
|
|
470
|
-
const s = stub(t);
|
|
471
|
-
const { code, json } = run(9, {
|
|
472
|
-
apply: true,
|
|
473
|
-
env: s.env({ CLOSES: "7", COMMITS: "Closes #007", LABELS_7: "in-progress" }),
|
|
474
|
-
});
|
|
475
|
-
assert.equal(code, 0);
|
|
476
|
-
assert.deepEqual(json.issues, [{ issue: 7, hadLabel: true, removed: true }]);
|
|
477
|
-
const viewsOf7 = s.calls().filter((c) => c === "issue view 7 --json labels --jq .labels[].name");
|
|
478
|
-
assert.equal(viewsOf7.length, 1, "'007' and '7' name the same issue and must be looked up once, not twice");
|
|
479
|
-
});
|