@feigi/fleet-ctl 0.0.0
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/.claude-plugin/plugin.json +9 -0
- package/LICENSE +202 -0
- package/NOTICE +18 -0
- package/agents/fleet-finisher.agent.md +7 -0
- package/agents/fleet-implementer-alt.agent.md +210 -0
- package/agents/fleet-implementer.agent.md +210 -0
- package/agents/fleet-merge-bot.agent.md +7 -0
- package/agents/fleet-review-comments.agent.md +40 -0
- package/agents/fleet-review-correctness.agent.md +43 -0
- package/agents/fleet-review-runner.agent.md +73 -0
- package/agents/fleet-review-silent-failure.agent.md +49 -0
- package/agents/fleet-review-simplify.agent.md +46 -0
- package/agents/fleet-review-snapshot.agent.md +24 -0
- package/agents/fleet-review-tests.agent.md +46 -0
- package/agents/fleet-review-types.agent.md +41 -0
- package/agents/fleet-review-verifier.agent.md +29 -0
- package/commands/review-and-fix.md +98 -0
- package/commands/run-merge-bot.md +357 -0
- package/commands/run-team-help.md +17 -0
- package/package.json +23 -0
- package/scripts/agent-test-dir-prose.test.mjs +59 -0
- package/scripts/agent-test.test.mjs +1636 -0
- package/scripts/ambient-git-vars-mjs-prose.test.mjs +354 -0
- package/scripts/ambient-git-vars-prose.test.mjs +192 -0
- package/scripts/ancestry-check-position-prose.test.mjs +175 -0
- package/scripts/apply-ruleset.test.mjs +420 -0
- package/scripts/arg-header-probes-prose.test.mjs +393 -0
- package/scripts/arg.mjs +600 -0
- package/scripts/arg.test.mjs +1354 -0
- package/scripts/board-cli.test.mjs +694 -0
- package/scripts/board-identity.test.mjs +429 -0
- package/scripts/board-liveness-banner.test.mjs +119 -0
- package/scripts/board-prev-shape.test.mjs +229 -0
- package/scripts/board-tryparse-null.test.mjs +119 -0
- package/scripts/board.html +471 -0
- package/scripts/board.mjs +2037 -0
- package/scripts/board.test.mjs +3086 -0
- package/scripts/brief-after-cut-prose.test.mjs +53 -0
- package/scripts/candidates-exit3-prose.test.mjs +302 -0
- package/scripts/candidates.mjs +674 -0
- package/scripts/candidates.test.mjs +2101 -0
- package/scripts/caveat-unification-prose.test.mjs +98 -0
- package/scripts/ci-comment-rot-prose.test.mjs +2025 -0
- package/scripts/ci-completes-premise-prose.test.mjs +257 -0
- package/scripts/ci-state-prose.test.mjs +113 -0
- package/scripts/ci-state.mjs +761 -0
- package/scripts/ci-state.test.mjs +1640 -0
- package/scripts/ci-vacuous-green.test.mjs +368 -0
- package/scripts/citation-sweep-prose.test.mjs +1572 -0
- package/scripts/claim-lifecycle.test.mjs +185 -0
- package/scripts/claim-ticket.sh +417 -0
- package/scripts/claim-ticket.test.mjs +1121 -0
- package/scripts/closing-keyword-prose.test.mjs +193 -0
- package/scripts/cockpit-launch-idempotent-prose.test.mjs +165 -0
- package/scripts/cockpit-tick-nonblocking.test.mjs +210 -0
- package/scripts/compute-board.mjs +579 -0
- package/scripts/compute-board.test.mjs +1060 -0
- package/scripts/compute-spend.mjs +329 -0
- package/scripts/compute-spend.test.mjs +451 -0
- package/scripts/cross-repo-citation-prose.test.mjs +156 -0
- package/scripts/cwd-isolation-pins.mjs +83 -0
- package/scripts/dedupe-guard-prose.test.mjs +243 -0
- package/scripts/derive-testcmd.sh +239 -0
- package/scripts/derive-testcmd.test.mjs +380 -0
- package/scripts/diff-stats.mjs +231 -0
- package/scripts/diff-stats.test.mjs +408 -0
- package/scripts/dispatch-block-golden-prose.test.mjs +1024 -0
- package/scripts/dispatch-block-pins-prose.test.mjs +615 -0
- package/scripts/drop-merged-label.sh +173 -0
- package/scripts/drop-merged-label.test.mjs +480 -0
- package/scripts/expected-jobs-prose.test.mjs +80 -0
- package/scripts/filing-bar-seat-prose.test.mjs +242 -0
- package/scripts/filing-claim-bar-prose.test.mjs +166 -0
- package/scripts/finisher-dispatch-premise-prose.test.mjs +312 -0
- package/scripts/finisher-halt-prose.test.mjs +106 -0
- package/scripts/finisher-name-prose.test.mjs +134 -0
- package/scripts/finisher-own-tree-prose.test.mjs +285 -0
- package/scripts/finisher-pin-race-prose.test.mjs +339 -0
- package/scripts/fix-applier-correction-rules-prose.test.mjs +201 -0
- package/scripts/fix-applier-result-file-prose.test.mjs +100 -0
- package/scripts/fleet-bootstrap +155 -0
- package/scripts/fleet-heartbeat.mjs +272 -0
- package/scripts/fleet-heartbeat.test.mjs +450 -0
- package/scripts/fleet-provenance +207 -0
- package/scripts/fleet-provenance.test.mjs +64 -0
- package/scripts/fleet-run +148 -0
- package/scripts/fleet-run.test.mjs +90 -0
- package/scripts/fleet-state.mjs +400 -0
- package/scripts/fleet-state.test.mjs +373 -0
- package/scripts/fleet-tick-prose.test.mjs +299 -0
- package/scripts/fleet-tick.mjs +832 -0
- package/scripts/fleet-tick.test.mjs +1332 -0
- package/scripts/force-with-lease-reason-prose.test.mjs +184 -0
- package/scripts/frontmatter-allowlist.json +64 -0
- package/scripts/frontmatter-check.mjs +256 -0
- package/scripts/frontmatter-check.test.mjs +436 -0
- package/scripts/git-env.mjs +124 -0
- package/scripts/git-env.test.mjs +149 -0
- package/scripts/git-status-untracked-mode-sweep.test.mjs +216 -0
- package/scripts/gone-walk.test.mjs +213 -0
- package/scripts/gp-sep-invariant-prose.test.mjs +188 -0
- package/scripts/head-moved-after-label-prose.test.mjs +233 -0
- package/scripts/immutable-body-claim-prose.test.mjs +413 -0
- package/scripts/implementer-model-tier.test.mjs +643 -0
- package/scripts/inflight-citation-prose.test.mjs +144 -0
- package/scripts/inflight-exit2-prose.test.mjs +81 -0
- package/scripts/inflight-probe-guard-prose.test.mjs +109 -0
- package/scripts/inflight-scan-scope-prose.test.mjs +57 -0
- package/scripts/inflight.sh +1106 -0
- package/scripts/inflight.test.mjs +2984 -0
- package/scripts/injection-control-prose.test.mjs +404 -0
- package/scripts/install-root-audit.test.mjs +464 -0
- package/scripts/instrument-check-prose.test.mjs +235 -0
- package/scripts/instruments.sh +394 -0
- package/scripts/instruments.test.mjs +787 -0
- package/scripts/issue-tracker-prose.test.mjs +71 -0
- package/scripts/json.sh +248 -0
- package/scripts/json.test.mjs +364 -0
- package/scripts/ledger-dispatch.test.mjs +516 -0
- package/scripts/ledger-grammar.mjs +85 -0
- package/scripts/ledger-grammar.test.mjs +142 -0
- package/scripts/ledger-read-require-file.test.mjs +197 -0
- package/scripts/ledger.mjs +1753 -0
- package/scripts/ledger.test.mjs +3554 -0
- package/scripts/line-distance-prose.test.mjs +245 -0
- package/scripts/liveness-rationale-prose.test.mjs +83 -0
- package/scripts/locale-pin-prose.test.mjs +189 -0
- package/scripts/member-outcome-prose.test.mjs +167 -0
- package/scripts/member-outcomes-header.test.mjs +148 -0
- package/scripts/member-outcomes-prose.test.mjs +63 -0
- package/scripts/member-outcomes.mjs +231 -0
- package/scripts/member-outcomes.test.mjs +507 -0
- package/scripts/member-prompt-prose.test.mjs +161 -0
- package/scripts/member-record.mjs +605 -0
- package/scripts/member-record.test.mjs +516 -0
- package/scripts/member-write-guard.mjs +279 -0
- package/scripts/member-write-guard.test.mjs +211 -0
- package/scripts/merge-commit-probe-prose.test.mjs +122 -0
- package/scripts/merge-gate.mjs +262 -0
- package/scripts/merge-gate.test.mjs +613 -0
- package/scripts/muted-git-guard-sweep.test.mjs +493 -0
- package/scripts/net-ssh-precedence-prose.test.mjs +91 -0
- package/scripts/net-watchdog-prose.test.mjs +79 -0
- package/scripts/net.sh +409 -0
- package/scripts/net.test.mjs +211 -0
- package/scripts/no-ci-gate-prose.test.mjs +108 -0
- package/scripts/no-undo-audit.sh +1134 -0
- package/scripts/no-undo-audit.test.mjs +3965 -0
- package/scripts/no-wave.test.mjs +138 -0
- package/scripts/node-floor-sweep.test.mjs +611 -0
- package/scripts/pointer-target-prose.test.mjs +186 -0
- package/scripts/pr-overlap.mjs +417 -0
- package/scripts/pr-overlap.test.mjs +695 -0
- package/scripts/printf-die-sweep.test.mjs +384 -0
- package/scripts/prompt-renderer.mjs +39 -0
- package/scripts/prompt-renderer.test.mjs +68 -0
- package/scripts/prose-pin.mjs +808 -0
- package/scripts/prose-pin.test.mjs +1034 -0
- package/scripts/prove-merge.sh +228 -0
- package/scripts/prove-merge.test.mjs +995 -0
- package/scripts/pull-table-relabel-prose.test.mjs +60 -0
- package/scripts/quiet-payload-prose.test.mjs +222 -0
- package/scripts/reap.sh +1768 -0
- package/scripts/reap.test.mjs +4395 -0
- package/scripts/reaping-prose.test.mjs +159 -0
- package/scripts/refuter-scratch-prose.test.mjs +135 -0
- package/scripts/release-label-required-prose.test.mjs +71 -0
- package/scripts/release-label-split-prose.test.mjs +169 -0
- package/scripts/release-ticket.sh +1716 -0
- package/scripts/release-ticket.test.mjs +5106 -0
- package/scripts/renovate-release-contract.test.mjs +379 -0
- package/scripts/repo-root.mjs +544 -0
- package/scripts/repo-root.test.mjs +873 -0
- package/scripts/reporter-output-rule-prose.test.mjs +208 -0
- package/scripts/review-agent-report-only.test.mjs +49 -0
- package/scripts/review-core-cwd-isolation.test.mjs +374 -0
- package/scripts/review-core-reads.test.mjs +478 -0
- package/scripts/review-core-refuter-scratch.test.mjs +148 -0
- package/scripts/review-core-snapshot-path.test.mjs +777 -0
- package/scripts/review-core-specialist-scratch.test.mjs +189 -0
- package/scripts/review-core-testcmd.test.mjs +288 -0
- package/scripts/review-core-unrun.test.mjs +530 -0
- package/scripts/review-core-unverified-discriminant.test.mjs +208 -0
- package/scripts/review-core.mjs +1028 -0
- package/scripts/review-eval-resolver-path.test.mjs +55 -0
- package/scripts/review-eval.mjs +197 -0
- package/scripts/review-host-fixture.mjs +73 -0
- package/scripts/review-in-run-retry.test.mjs +187 -0
- package/scripts/review-no-vendor-dispatch.test.mjs +45 -0
- package/scripts/review-path-default.test.mjs +796 -0
- package/scripts/review-runner-spawns.test.mjs +93 -0
- package/scripts/review-runner.test.mjs +155 -0
- package/scripts/review-tier-audit.test.mjs +140 -0
- package/scripts/run-artifact-pr-prose.test.mjs +341 -0
- package/scripts/run-merge-bot-prose.test.mjs +1391 -0
- package/scripts/scratch-partition-invariant-prose.test.mjs +74 -0
- package/scripts/scripts-path-citation-sweep.test.mjs +73 -0
- package/scripts/section-between-guard-prose.test.mjs +378 -0
- package/scripts/select-dimensions.test.mjs +674 -0
- package/scripts/shared-refusal.test.mjs +388 -0
- package/scripts/shell-traps-prose.test.mjs +507 -0
- package/scripts/shortlist.mjs +355 -0
- package/scripts/shortlist.test.mjs +366 -0
- package/scripts/slow-transport.mjs +72 -0
- package/scripts/snapshot-repo.test.mjs +772 -0
- package/scripts/snapshot-runner-audience-prose.test.mjs +129 -0
- package/scripts/spend-view.test.mjs +312 -0
- package/scripts/staleness-qualifier-prose.test.mjs +251 -0
- package/scripts/staleness-verdict-prose.test.mjs +142 -0
- package/scripts/staleness.mjs +414 -0
- package/scripts/staleness.test.mjs +893 -0
- package/scripts/stalled-member-liveness-prose.test.mjs +219 -0
- package/scripts/stash-prohibition-prose.test.mjs +313 -0
- package/scripts/strip-comments.mjs +44 -0
- package/scripts/tier-check.mjs +468 -0
- package/scripts/tier-check.test.mjs +726 -0
- package/scripts/tier-guard-gate-prose.test.mjs +216 -0
- package/scripts/tier-outcomes-header.test.mjs +586 -0
- package/scripts/tier-outcomes.mjs +441 -0
- package/scripts/tier-outcomes.test.mjs +342 -0
- package/scripts/tier-roles.mjs +250 -0
- package/scripts/tier-roles.test.mjs +316 -0
- package/scripts/tracker-block-copy-prose.test.mjs +288 -0
- package/scripts/triage-labels-gloss-prose.test.mjs +97 -0
- package/scripts/unattended-git-sweep.test.mjs +142 -0
- package/scripts/verify-sha-exit2-prose.test.mjs +269 -0
- package/scripts/verify-sha.sh +117 -0
- package/scripts/verify-sha.test.mjs +693 -0
- package/scripts/watcher-degraded-block.test.mjs +372 -0
- package/scripts/watcher-key-prose.test.mjs +106 -0
- package/scripts/within-run-pair-prose.test.mjs +208 -0
- package/scripts/worktree-audit.sh +482 -0
- package/scripts/worktree-audit.test.mjs +1407 -0
- package/scripts/worktree-head-prose.test.mjs +276 -0
- package/scripts/worktree-listing-sweep.test.mjs +217 -0
- package/scripts/worktree-model-prose.test.mjs +216 -0
- package/scripts/worktree.sh +470 -0
- package/skills/next-ticket/SKILL.md +138 -0
- package/skills/run-team/SKILL.md +3603 -0
- package/skills/run-team/references/ci-and-staleness.md +75 -0
- package/skills/run-team/references/correction-tickets.md +37 -0
- package/skills/run-team/references/isolation.md +23 -0
- package/skills/run-team/references/member-lifecycle.md +73 -0
- package/skills/run-team/references/reaping.md +73 -0
- package/skills/sizing-a-ticket/SKILL.md +39 -0
|
@@ -0,0 +1,772 @@
|
|
|
1
|
+
// #1056. The review snapshot was cut with `git archive HEAD | tar -x` and
|
|
2
|
+
// nothing more, so it was not a git repository — and this repo's suite has
|
|
3
|
+
// whole files that ask git what ships rather than walking the directory, which
|
|
4
|
+
// need a `.git` at or above them. Measured at `ffa9026`, one commit three ways,
|
|
5
|
+
// `env -u FORCE_COLOR node --test` from each tree's root:
|
|
6
|
+
//
|
|
7
|
+
// a worktree tests 2401 pass 2401 fail 0 skipped 0
|
|
8
|
+
// a bare `git archive` extraction tests 2401 pass 2382 fail 0 skipped 19
|
|
9
|
+
// an extraction this block initialized tests 2401 pass 2401 fail 0 skipped 0
|
|
10
|
+
//
|
|
11
|
+
// The middle row is what every dimension used to report: the same `tests`
|
|
12
|
+
// total, `fail 0`, and 19 checks that never ran — invisible, because a total
|
|
13
|
+
// that matches reads as a suite that ran. Before those files learned to decline
|
|
14
|
+
// (#1149) the same cause hard-FAILED them instead, and two dimensions in one
|
|
15
|
+
// run filed nothing at all over a red they could not attribute.
|
|
16
|
+
//
|
|
17
|
+
// EXECUTED, not text-pinned, and that distinction is the whole point of this
|
|
18
|
+
// file: `review-core-snapshot-path.test.mjs` pins the block's lines and their
|
|
19
|
+
// ORDER as text, which stays green on a sequence that is spelled right and does
|
|
20
|
+
// not work — a `git add` that skips a tracked-but-ignored file, an init that a
|
|
21
|
+
// stale `GIT_DIR` sends elsewhere, a commit an unconfigured identity refuses.
|
|
22
|
+
// Each of those is a real environment an unattended snapshot agent runs in, and
|
|
23
|
+
// none of them is visible in the source text. So every test below RUNS the
|
|
24
|
+
// block's own lines, lifted from review-core.mjs, against a fixture
|
|
25
|
+
// repository it builds itself.
|
|
26
|
+
//
|
|
27
|
+
// Fixtures only: every test here builds its own repository under `$TMPDIR`, so
|
|
28
|
+
// none of them needs an ambient working tree and none declines in an extraction
|
|
29
|
+
// (the condition this ticket is about). The one thing they need is `git`.
|
|
30
|
+
//
|
|
31
|
+
// Zero deps: `node --test plugin/scripts/snapshot-repo.test.mjs`.
|
|
32
|
+
import { test } from "node:test";
|
|
33
|
+
import assert from "node:assert/strict";
|
|
34
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
35
|
+
import { existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
|
36
|
+
import { tmpdir } from "node:os";
|
|
37
|
+
import { dirname, join } from "node:path";
|
|
38
|
+
import { environmentNote } from "./review-core.mjs";
|
|
39
|
+
import { between, phrase } from "./prose-pin.mjs";
|
|
40
|
+
import { stripComments } from "./strip-comments.mjs";
|
|
41
|
+
|
|
42
|
+
const REPO = join(import.meta.dirname, "..");
|
|
43
|
+
const SOURCES = [["scripts/review-core.mjs", join(REPO, "scripts", "review-core.mjs")]];
|
|
44
|
+
|
|
45
|
+
// Every git identity is scrubbed — both config files and all four `GIT_*` name
|
|
46
|
+
// and email variables — so the commit the block takes can only be the one the
|
|
47
|
+
// block's own `-c user.name`/`-c user.email` supply. That does NOT make the
|
|
48
|
+
// commit impossible without them: measured here, git auto-detects an identity
|
|
49
|
+
// from the OS and committed as `Christian Ziegler <chris@Mac.fritz.box>` with
|
|
50
|
+
// both config files pointed at /dev/null
|
|
51
|
+
// (`env -u GIT_AUTHOR_NAME … GIT_CONFIG_GLOBAL=/dev/null git commit`). So the
|
|
52
|
+
// flags are pinned by the AUTHOR assertion below rather than by a refusal:
|
|
53
|
+
// unflagged, a review stamps whoever's machine ran it onto a commit nobody
|
|
54
|
+
// wrote, and on a host whose name gives git no address it can form the commit
|
|
55
|
+
// fails outright instead.
|
|
56
|
+
//
|
|
57
|
+
// `GIT_DIR`/`GIT_WORK_TREE`/`GIT_INDEX_FILE` are cleared for a different
|
|
58
|
+
// reason: inherited, `git init` exits 0 and creates nothing in the target, so a
|
|
59
|
+
// fixture built under an ambient GIT_DIR would be no repository at all while
|
|
60
|
+
// every status check passed (repo-root.test.mjs's own measurement).
|
|
61
|
+
// `GIT_TEMPLATE_DIR` joins them (#1056): an ambient template directory with no
|
|
62
|
+
// `info/` subdirectory makes `git init` produce no `.git/info`, so the block's
|
|
63
|
+
// `.git/info/exclude` append silently fails and every fixture below would be
|
|
64
|
+
// measuring the ambient host's template instead of the hazard this file
|
|
65
|
+
// exists to catch.
|
|
66
|
+
const ENV = {
|
|
67
|
+
...process.env,
|
|
68
|
+
GIT_DIR: undefined,
|
|
69
|
+
GIT_WORK_TREE: undefined,
|
|
70
|
+
GIT_INDEX_FILE: undefined,
|
|
71
|
+
GIT_TEMPLATE_DIR: undefined,
|
|
72
|
+
GIT_AUTHOR_NAME: undefined,
|
|
73
|
+
GIT_AUTHOR_EMAIL: undefined,
|
|
74
|
+
GIT_COMMITTER_NAME: undefined,
|
|
75
|
+
GIT_COMMITTER_EMAIL: undefined,
|
|
76
|
+
GIT_CONFIG_GLOBAL: "/dev/null",
|
|
77
|
+
GIT_CONFIG_SYSTEM: "/dev/null",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const git = (dir, ...args) => execFileSync("git", ["-C", dir, ...args], { env: ENV, encoding: "utf8" }).trim();
|
|
81
|
+
|
|
82
|
+
function scratch(t, prefix) {
|
|
83
|
+
const dir = realpathSync(mkdtempSync(join(tmpdir(), prefix)));
|
|
84
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
85
|
+
return dir;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A repository standing in for the worktree under review. Deliberately carries
|
|
90
|
+
* the three shapes that separate a faithful snapshot from a plausible one: a
|
|
91
|
+
* nested path, an executable bit, and a file this repo's own `.gitignore`
|
|
92
|
+
* covers while git tracks it anyway — legal, present in `git archive`'s output,
|
|
93
|
+
* and skipped by a plain `git add`.
|
|
94
|
+
*
|
|
95
|
+
* `exportIgnore` marks one tracked file `export-ignore`, which is the one way a
|
|
96
|
+
* `git archive` legitimately does NOT carry the whole tree. That fixture is the
|
|
97
|
+
* honest-refusal case, not a bug to fix: the snapshot really is not the
|
|
98
|
+
* reviewed tree, and the block has to say so rather than report a match.
|
|
99
|
+
*/
|
|
100
|
+
function reviewedRepo(t, { exportIgnore = false } = {}) {
|
|
101
|
+
const dir = scratch(t, "snapshot-repo-src-");
|
|
102
|
+
git(dir, "init", "-q");
|
|
103
|
+
mkdirSync(join(dir, "nested"), { recursive: true });
|
|
104
|
+
writeFileSync(join(dir, "nested", "run.sh"), "#!/bin/sh\necho ran\n", { mode: 0o755 });
|
|
105
|
+
writeFileSync(join(dir, "plain.txt"), "content\n");
|
|
106
|
+
writeFileSync(join(dir, ".gitignore"), "ignored.txt\n");
|
|
107
|
+
writeFileSync(join(dir, "ignored.txt"), "tracked anyway\n");
|
|
108
|
+
if (exportIgnore) writeFileSync(join(dir, ".gitattributes"), "plain.txt export-ignore\n");
|
|
109
|
+
git(dir, "add", "-A", "-f");
|
|
110
|
+
git(dir, "-c", "user.name=fixture", "-c", "user.email=fixture@invalid", "commit", "-q", "-m", "fixture");
|
|
111
|
+
return dir;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The lines under test, lifted from review-core.mjs's snapshot prompt and rendered
|
|
116
|
+
* with the same `${worktree}` interpolation the script performs: the archive,
|
|
117
|
+
* the emptiness probe, the init/commit, the tree compare, the exclude and the
|
|
118
|
+
* symlink. `$SNAP` and `$SHA` are the shell's, supplied by `cut` below — the
|
|
119
|
+
* lines that mint them are pinned by `review-core-snapshot-path.test.mjs`'s own
|
|
120
|
+
* executed mint test, and repeating that here would test its subject twice
|
|
121
|
+
* while testing this one no better.
|
|
122
|
+
*/
|
|
123
|
+
function cutLines(path) {
|
|
124
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
125
|
+
const from = code.search(/^ *git -C \$\{worktree\} archive HEAD/m);
|
|
126
|
+
const to = code.search(/^ *if \[ -n "\$SNAP" \] && \[ -d \$\{worktree\}\/node_modules \]/m);
|
|
127
|
+
assert.ok(
|
|
128
|
+
from !== -1 && to > from,
|
|
129
|
+
`${path} no longer runs from a \`git archive\` down to the node_modules symlink — the block was reshaped past what this test lifts; update it or restore the block`,
|
|
130
|
+
);
|
|
131
|
+
return code.slice(from, code.indexOf("\n", to));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** `cutLines`, rendered for one worktree. */
|
|
135
|
+
const render = (path, worktree) => new Function("worktree", "return `" + cutLines(path) + "`")(worktree);
|
|
136
|
+
|
|
137
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The stale-run-root prune, lifted by its own named marker rather than by the
|
|
141
|
+
* `find` expression that currently implements it. The marker is the line's
|
|
142
|
+
* identity in this block's output vocabulary, so a rewrite of the expression
|
|
143
|
+
* still lifts and only a prune that is GONE reds the assertion here — the
|
|
144
|
+
* distinction `review-core-snapshot-path.test.mjs`'s own needle comment draws
|
|
145
|
+
* about pinning "the shape that decides behaviour and nothing else".
|
|
146
|
+
*
|
|
147
|
+
* The line carries no shell variables, only the script's `${runRootParent}`,
|
|
148
|
+
* so it renders to a standalone command and needs none of `cut`'s scaffolding.
|
|
149
|
+
*/
|
|
150
|
+
function pruneLine(path) {
|
|
151
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
152
|
+
const m = code.match(/^ *[^\n]*SNAPSHOT_PRUNE_FAILED[^\n]*$/m);
|
|
153
|
+
assert.ok(
|
|
154
|
+
m,
|
|
155
|
+
`${path} no longer prunes stale run roots out of the per-PR parent — #1083's growth half is back, and every review leaves a tree nothing ever removes`,
|
|
156
|
+
);
|
|
157
|
+
return m[0].trim();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** `pruneLine`, rendered for one per-PR parent directory. */
|
|
161
|
+
const renderPrune = (path, runRootParent) =>
|
|
162
|
+
new Function("runRootParent", "return `" + pruneLine(path) + "`")(runRootParent);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* `cutLines`'s slice, prefixed with the block's own ambient-var clearing
|
|
166
|
+
* line — pulled from the source by its literal text rather than assumed, so
|
|
167
|
+
* a rewrap or a dropped var still fails this the same way
|
|
168
|
+
* review-core-snapshot-path.test.mjs's own sequence pin would. Neither
|
|
169
|
+
* `cutLines` nor `render` widen to include it: in the real script the
|
|
170
|
+
* clearing line sits ABOVE `${scratch}`/`${runRootParent}`, and pulling it
|
|
171
|
+
* into `render`'s narrow, worktree-only `new Function` would need those too.
|
|
172
|
+
*/
|
|
173
|
+
function withUnset(path) {
|
|
174
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
175
|
+
const m = code.match(/^ *unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_TEMPLATE_DIR *$/m);
|
|
176
|
+
assert.ok(m, `${path} no longer clears the ambient git vars before the snapshot block — the hoist this test depends on is gone (#1056)`);
|
|
177
|
+
return `${m[0]}\n${cutLines(path)}`;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** `withUnset`, rendered for one worktree. */
|
|
181
|
+
const renderWithUnset = (path, worktree) => new Function("worktree", "return `" + withUnset(path) + "`")(worktree);
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The ref-selection lines and the line that prints their answer, lifted from
|
|
185
|
+
* review-core.mjs's snapshot prompt (#1616). `$branch` and `$crossRepo` are the
|
|
186
|
+
* shell's, minted by the `gh pr view` lines just above them — supplied by
|
|
187
|
+
* `readRef` below, because `gh` cannot run against a fixture and those two
|
|
188
|
+
* values are the only things these lines take from it.
|
|
189
|
+
*/
|
|
190
|
+
function refLines(path) {
|
|
191
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
192
|
+
const from = code.search(/^ *ref=""$/m);
|
|
193
|
+
const to = code.search(/^ *echo "\$ref"$/m);
|
|
194
|
+
assert.ok(
|
|
195
|
+
from !== -1 && to > from,
|
|
196
|
+
`${path} no longer selects the ref by crossRepo and echoes the result — the reads were reshaped past what this test lifts; update it or restore them`,
|
|
197
|
+
);
|
|
198
|
+
return code.slice(from, code.indexOf("\n", to));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** `refLines`, rendered for one worktree and PR number. */
|
|
202
|
+
const renderRefs = (path, worktree, pr) => new Function("worktree", "pr", "return `" + refLines(path) + "`")(worktree, pr);
|
|
203
|
+
|
|
204
|
+
const REAL_GIT = execFileSync("sh", ["-c", "command -v git"], { env: ENV, encoding: "utf8" }).trim();
|
|
205
|
+
const BRANCH = "contributor/fork-feature";
|
|
206
|
+
const PR = 1616;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* A bare repository standing in for `origin`, carrying whichever of the two
|
|
210
|
+
* refs the case under test needs, plus a worktree whose `origin` remote points
|
|
211
|
+
* at it.
|
|
212
|
+
*
|
|
213
|
+
* The two refs hold DIFFERENT commits deliberately. That is what makes "which
|
|
214
|
+
* ref answered" observable at all: with one sha under both names every
|
|
215
|
+
* ordering of the two reads prints the same thing, and the same-repo case
|
|
216
|
+
* could not be told apart from the fork case by the value.
|
|
217
|
+
*/
|
|
218
|
+
function remoteFixture(t, { branchRef = true, pullRef = true } = {}) {
|
|
219
|
+
const src = scratch(t, "snapshot-refs-src-");
|
|
220
|
+
const commit = (m) => git(src, "-c", "user.name=fixture", "-c", "user.email=fixture@invalid", "commit", "-q", "-m", m);
|
|
221
|
+
git(src, "init", "-q");
|
|
222
|
+
writeFileSync(join(src, "a.txt"), "the branch head\n");
|
|
223
|
+
git(src, "add", "-A");
|
|
224
|
+
commit("branch head");
|
|
225
|
+
const branchSha = git(src, "rev-parse", "HEAD");
|
|
226
|
+
writeFileSync(join(src, "a.txt"), "the PR head\n");
|
|
227
|
+
git(src, "add", "-A");
|
|
228
|
+
commit("pull head");
|
|
229
|
+
const pullSha = git(src, "rev-parse", "HEAD");
|
|
230
|
+
assert.notEqual(branchSha, pullSha, "the fixture minted one sha for both refs, so every case below would prove nothing");
|
|
231
|
+
|
|
232
|
+
const origin = scratch(t, "snapshot-refs-origin-");
|
|
233
|
+
git(origin, "init", "-q", "--bare");
|
|
234
|
+
git(src, "remote", "add", "origin", origin);
|
|
235
|
+
git(src, "push", "-q", "origin", "HEAD:refs/fixture/objects");
|
|
236
|
+
if (branchRef) git(origin, "update-ref", `refs/heads/${BRANCH}`, branchSha);
|
|
237
|
+
if (pullRef) git(origin, "update-ref", `refs/pull/${PR}/head`, pullSha);
|
|
238
|
+
|
|
239
|
+
const worktree = scratch(t, "snapshot-refs-wt-");
|
|
240
|
+
git(worktree, "init", "-q");
|
|
241
|
+
git(worktree, "remote", "add", "origin", origin);
|
|
242
|
+
return { worktree, branchSha, pullSha };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* A `git` that records every invocation before delegating to the real one, so
|
|
247
|
+
* "the PR ref is not consulted" is measured as a READ COUNT rather than
|
|
248
|
+
* inferred from the value. The value cannot carry that claim on its own: a
|
|
249
|
+
* block that ran both reads and kept the first prints exactly what one that
|
|
250
|
+
* stopped after the first prints, and the second network round-trip a
|
|
251
|
+
* same-repo PR must not pay is invisible in the output.
|
|
252
|
+
*/
|
|
253
|
+
function tracingGit(t) {
|
|
254
|
+
const dir = scratch(t, "snapshot-refs-bin-");
|
|
255
|
+
const log = join(dir, "calls.log");
|
|
256
|
+
writeFileSync(join(dir, "git"), `#!/bin/sh\nprintf '%s\\n' "$*" >> ${JSON.stringify(log)}\nexec ${JSON.stringify(REAL_GIT)} "$@"\n`, {
|
|
257
|
+
mode: 0o755,
|
|
258
|
+
});
|
|
259
|
+
return {
|
|
260
|
+
dir,
|
|
261
|
+
reads: () => (existsSync(log) ? readFileSync(log, "utf8").split("\n").filter((l) => l.includes("ls-remote")) : []),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** Runs the rendered ref reads with `$branch` and `$crossRepo` supplied and the tracing git first on PATH. */
|
|
266
|
+
function readRef(script, bin, branch = BRANCH, crossRepo = "false") {
|
|
267
|
+
const r = spawnSync(
|
|
268
|
+
"sh",
|
|
269
|
+
["-c", [`branch=${JSON.stringify(branch)}`, `crossRepo=${JSON.stringify(crossRepo)}`, script].join("\n")],
|
|
270
|
+
{ env: { ...ENV, PATH: `${bin}:${process.env.PATH}` }, encoding: "utf8" },
|
|
271
|
+
);
|
|
272
|
+
return { out: (r.stdout ?? "").trim(), err: r.stderr ?? "", status: r.status };
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Runs a rendered block and returns what it printed plus where it wrote. The
|
|
277
|
+
* status is returned rather than asserted: two tests below are about a block
|
|
278
|
+
* whose `git archive` FAILS, and that is a scenario, not a test failure.
|
|
279
|
+
*/
|
|
280
|
+
function cut(t, script, { snapName = "snapshot-deadbee", env = ENV } = {}) {
|
|
281
|
+
const runRoot = scratch(t, "snapshot-repo-run-");
|
|
282
|
+
const snap = join(runRoot, snapName);
|
|
283
|
+
const r = spawnSync(
|
|
284
|
+
"sh",
|
|
285
|
+
["-c", ["SHA=deadbee", `SNAP=${JSON.stringify(snap)}`, 'mkdir -p "$SNAP"', script].join("\n")],
|
|
286
|
+
{ env, encoding: "utf8" },
|
|
287
|
+
);
|
|
288
|
+
return { snap, out: r.stdout ?? "", err: r.stderr ?? "", status: r.status };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
for (const [name, path] of SOURCES) {
|
|
292
|
+
// The accept case, and the property the whole ticket turns on: the snapshot
|
|
293
|
+
// is a repository, and it is a repository holding the REVIEWED tree. The tree
|
|
294
|
+
// hash is what settles the second half — two commits whose trees hash the
|
|
295
|
+
// same hold byte-identical content, every file, which is strictly more than
|
|
296
|
+
// the "confirm a couple of the diff's files" spot check this replaced.
|
|
297
|
+
test(`${name}: the block leaves a repository whose commit holds the reviewed tree`, (t) => {
|
|
298
|
+
const worktree = reviewedRepo(t);
|
|
299
|
+
const { snap, out, status } = cut(t, render(path, worktree));
|
|
300
|
+
|
|
301
|
+
assert.match(out, /SNAPSHOT_NONEMPTY/, `the extraction came back empty: ${out}`);
|
|
302
|
+
assert.doesNotMatch(out, /SNAPSHOT_INIT_FAILED/, `the init or the commit failed: ${out}`);
|
|
303
|
+
assert.match(out, /SNAPSHOT_TREE_MATCH/, `the block did not settle that the snapshot is the reviewed tree: ${out}`);
|
|
304
|
+
assert.equal(status, 0, "the block exited non-zero — a snapshot agent reads that as a failed cut");
|
|
305
|
+
|
|
306
|
+
assert.ok(existsSync(join(snap, ".git")), "there is no `.git` in the snapshot — every suite that asks git what ships declines or fails there");
|
|
307
|
+
assert.equal(
|
|
308
|
+
git(snap, "rev-parse", "HEAD^{tree}"),
|
|
309
|
+
git(worktree, "rev-parse", "HEAD^{tree}"),
|
|
310
|
+
"the snapshot's commit does not hold the reviewed tree",
|
|
311
|
+
);
|
|
312
|
+
// The identity flags, pinned where they have an observable effect. The
|
|
313
|
+
// snapshot commit is a mechanism, not a contribution, and nothing about it
|
|
314
|
+
// is the operator's: unflagged, git auto-detects a name and address off the
|
|
315
|
+
// machine (measured in the header) and every review in the fleet stamps
|
|
316
|
+
// whoever ran it onto a commit nobody wrote.
|
|
317
|
+
assert.equal(
|
|
318
|
+
git(snap, "log", "-1", "--format=%an <%ae>"),
|
|
319
|
+
"fleet <fleet@invalid>",
|
|
320
|
+
"the snapshot commit is not attributed to the block's own synthetic identity",
|
|
321
|
+
);
|
|
322
|
+
// The `-f` on `git add`, measured rather than read off the flag: this file
|
|
323
|
+
// is tracked at HEAD, so `git archive` carries it, and the extraction's own
|
|
324
|
+
// `.gitignore` is what would make a plain `git add -A` skip it. Dropping
|
|
325
|
+
// `-f` also breaks the tree compare above — but this assertion names the
|
|
326
|
+
// cause, and the hash comparison cannot.
|
|
327
|
+
assert.equal(
|
|
328
|
+
git(snap, "ls-files", "--error-unmatch", "ignored.txt"),
|
|
329
|
+
"ignored.txt",
|
|
330
|
+
"a tracked file the repo's own .gitignore covers did not make it into the snapshot's index",
|
|
331
|
+
);
|
|
332
|
+
// The exec bit is part of the tree object, so a mode the extraction lost
|
|
333
|
+
// would already have reddened the hash. Asserted anyway because it is the
|
|
334
|
+
// one property a reader checks by hand when a suite behaves differently in
|
|
335
|
+
// the snapshot, and a named assertion beats re-deriving it from a hash.
|
|
336
|
+
assert.match(git(snap, "ls-files", "-s", "nested/run.sh"), /^100755 /, "the executable bit did not survive into the snapshot");
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
// The negative control for the test above. Without it, "there is a repository
|
|
340
|
+
// at the snapshot" is satisfiable by an ambient repository ABOVE the snapshot
|
|
341
|
+
// — `$TMPDIR` inside a checkout, a stray `.git` in a temp root — and the pin
|
|
342
|
+
// would pass with the init deleted.
|
|
343
|
+
test(`${name}: without the block's init the same extraction is not a repository`, (t) => {
|
|
344
|
+
const worktree = reviewedRepo(t);
|
|
345
|
+
const lines = render(path, worktree).split("\n");
|
|
346
|
+
const extractOnly = lines.filter((l) => /archive HEAD/.test(l) || /ls -A/.test(l));
|
|
347
|
+
assert.equal(extractOnly.length, 2, "the archive and the probe are no longer one line each — update this control");
|
|
348
|
+
const { snap, out } = cut(t, extractOnly.join("\n"));
|
|
349
|
+
|
|
350
|
+
assert.match(out, /SNAPSHOT_NONEMPTY/, "the control's own extraction failed, so it controls nothing");
|
|
351
|
+
assert.ok(!existsSync(join(snap, ".git")), "the control extraction has a `.git` — it is not the pre-fix shape and proves nothing");
|
|
352
|
+
const probe = spawnSync("git", ["-C", snap, "rev-parse", "--show-toplevel"], {
|
|
353
|
+
env: { ...ENV, GIT_CEILING_DIRECTORIES: dirname(snap) },
|
|
354
|
+
encoding: "utf8",
|
|
355
|
+
});
|
|
356
|
+
assert.notEqual(probe.status, 0, "git answered for a bare extraction — the ceiling is wrong, or this environment nests the snapshot inside a repository");
|
|
357
|
+
assert.match(
|
|
358
|
+
probe.stderr,
|
|
359
|
+
/not a git repository/,
|
|
360
|
+
"the bare extraction failed for some reason OTHER than having no repository, so it is not the condition #1056 describes",
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// The ordering, executed. `review-core-snapshot-path.test.mjs` pins that the
|
|
365
|
+
// probe sits above the init as TEXT; this is why that order is load-bearing.
|
|
366
|
+
// A `git archive` that produced nothing — no auth, a dead HEAD — leaves the
|
|
367
|
+
// directory `mkdir -p` made, and `.git` is enough to make it look populated,
|
|
368
|
+
// in every repo rather than only the ones with node_modules.
|
|
369
|
+
test(`${name}: the emptiness probe still sees an empty extraction, and would not above the init`, (t) => {
|
|
370
|
+
const notARepo = scratch(t, "snapshot-repo-norepo-");
|
|
371
|
+
const lines = render(path, notARepo).split("\n");
|
|
372
|
+
const probeAt = lines.findIndex((l) => /ls -A/.test(l));
|
|
373
|
+
const initAt = lines.findIndex((l) => /git init -q/.test(l));
|
|
374
|
+
assert.ok(probeAt !== -1 && initAt > probeAt, "the block no longer probes above its init — the text pin in review-core-snapshot-path.test.mjs is the one to read first");
|
|
375
|
+
|
|
376
|
+
const real = cut(t, lines.join("\n"));
|
|
377
|
+
assert.match(
|
|
378
|
+
real.out,
|
|
379
|
+
/SNAPSHOT_EMPTY/,
|
|
380
|
+
`a failed archive must report SNAPSHOT_EMPTY so the caller refuses the tree (#140): ${real.out}`,
|
|
381
|
+
);
|
|
382
|
+
assert.doesNotMatch(real.out, /SNAPSHOT_NONEMPTY/, "the probe called a failed extraction non-empty");
|
|
383
|
+
assert.match(real.out, /SNAPSHOT_TREE_MISMATCH/, "a failed archive is also not the reviewed tree, and the block must say so");
|
|
384
|
+
|
|
385
|
+
const moved = [...lines];
|
|
386
|
+
moved.splice(initAt, 1);
|
|
387
|
+
moved.splice(probeAt, 0, lines[initAt]);
|
|
388
|
+
const swapped = cut(t, moved.join("\n"));
|
|
389
|
+
assert.match(
|
|
390
|
+
swapped.out,
|
|
391
|
+
/SNAPSHOT_NONEMPTY/,
|
|
392
|
+
"moving the init above the probe no longer fools the probe — if that is genuinely true the order is free, but it was measured false and the pin above rests on it",
|
|
393
|
+
);
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// What this change can wrongly REFUSE, and the answer it must give when it
|
|
397
|
+
// does: `export-ignore` keeps a tracked file out of `git archive`, so the
|
|
398
|
+
// snapshot genuinely is not the reviewed tree. The block reports that rather
|
|
399
|
+
// than a match — and the review still RUNS, because refusing would trade a
|
|
400
|
+
// wrong test count for no coverage at all, which is this defect's own
|
|
401
|
+
// expensive half (two dimensions in one run filed nothing over a suite they
|
|
402
|
+
// could not attribute).
|
|
403
|
+
test(`${name}: a snapshot the archive could not fill reports the mismatch and does not cancel the review`, (t) => {
|
|
404
|
+
const worktree = reviewedRepo(t, { exportIgnore: true });
|
|
405
|
+
const { snap, out } = cut(t, render(path, worktree));
|
|
406
|
+
|
|
407
|
+
assert.ok(!existsSync(join(snap, "plain.txt")), "the export-ignore fixture did not actually drop a file, so it exercises nothing");
|
|
408
|
+
assert.match(out, /SNAPSHOT_TREE_MISMATCH/, `an archive missing a tracked file must not report a match: ${out}`);
|
|
409
|
+
assert.doesNotMatch(out, /SNAPSHOT_TREE_MATCH/, "the block reported both outcomes");
|
|
410
|
+
assert.match(out, /SNAPSHOT_TREE_MISMATCH=snapshot [0-9a-f]{40} vs commit [0-9a-f]{40}/, "the mismatch names neither hash — a reader cannot tell which tree was measured");
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// Both prompts that order a suite run, and the payload. A fact reported to
|
|
414
|
+
// the caller and never told to the agent measuring in that environment is
|
|
415
|
+
// half a fix: the specialist is the one deciding whether a red is a finding.
|
|
416
|
+
test(`${name}: both suite-running prompts and the payload carry what the run is evidence about`, () => {
|
|
417
|
+
const code = stripComments(readFileSync(path, "utf8"));
|
|
418
|
+
const specialist = between(code, "READ ONLY FROM THE SNAPSHOT", "Report only what you RAN", "the specialist prompt");
|
|
419
|
+
const refuter = between(code, "Try to REFUTE this finding", "{ label: `verify:", "the refuter prompt");
|
|
420
|
+
assert.match(specialist, /\$\{environmentNote\(snap\)\}/, "the specialist prompt no longer says what its own suite run is evidence about — a dimension then reads a skip or a red as a fact about the tree");
|
|
421
|
+
assert.match(refuter, /\$\{environmentNote\(snap\)\}/, "the refuter prompt no longer carries it — a refuter that runs the suite to check a finding draws the same wrong conclusion");
|
|
422
|
+
assert.match(code, /testEnvironment: environmentNote\(snap\)/, "the returned payload no longer carries the measurement environment — the controller is back to reading a count with nothing saying where it was taken");
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// #1056 Finding 3: `unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE` used to sit
|
|
426
|
+
// INSIDE the init's own subshell, so the SHA capture, the archive and the
|
|
427
|
+
// tree-hash compare — all of them OUTSIDE that subshell — ran with an
|
|
428
|
+
// ambient GIT_DIR still outranking every `-C`. Measured: pointed at an
|
|
429
|
+
// unrelated repository, the old block archived and compared THAT repo
|
|
430
|
+
// instead of the worktree, and reported SNAPSHOT_TREE_MATCH for it. The
|
|
431
|
+
// fix hoists the clearing to the top of the whole block.
|
|
432
|
+
test(`${name}: an ambient GIT_DIR naming an unrelated repository does not retarget the snapshot`, (t) => {
|
|
433
|
+
const worktree = reviewedRepo(t);
|
|
434
|
+
const stranger = scratch(t, "snapshot-repo-stranger-");
|
|
435
|
+
git(stranger, "init", "-q");
|
|
436
|
+
writeFileSync(join(stranger, "stranger.txt"), "stranger\n");
|
|
437
|
+
git(stranger, "add", "-A");
|
|
438
|
+
git(stranger, "-c", "user.name=fixture", "-c", "user.email=fixture@invalid", "commit", "-q", "-m", "stranger");
|
|
439
|
+
|
|
440
|
+
const { snap, out } = cut(t, renderWithUnset(path, worktree), { env: { ...ENV, GIT_DIR: join(stranger, ".git") } });
|
|
441
|
+
|
|
442
|
+
assert.ok(!existsSync(join(snap, "stranger.txt")), `an ambient GIT_DIR retargeted the archive at the unrelated repository: ${out}`);
|
|
443
|
+
assert.ok(existsSync(join(snap, "plain.txt")), `the archive did not pull from the worktree under review: ${out}`);
|
|
444
|
+
assert.match(out, /SNAPSHOT_TREE_MATCH\b/, `an ambient GIT_DIR pointed at an unrelated repository must not stop the block from settling the real tree: ${out}`);
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
// #1056 Finding 4: an ambient GIT_TEMPLATE_DIR with no `info/` subdirectory
|
|
448
|
+
// makes `git init` skip populating `.git/info`, so the block's own
|
|
449
|
+
// `.git/info/exclude` append has nowhere to land and node_modules goes back
|
|
450
|
+
// to being untracked but NOT excluded — the exact dirty-status regression
|
|
451
|
+
// the symlink tests above guard against, reachable through the host's
|
|
452
|
+
// environment instead of through the diff.
|
|
453
|
+
test(`${name}: an ambient GIT_TEMPLATE_DIR with no info/ still leaves the snapshot clean`, (t) => {
|
|
454
|
+
const worktree = reviewedRepo(t);
|
|
455
|
+
mkdirSync(join(worktree, "node_modules"), { recursive: true });
|
|
456
|
+
const emptyTemplate = scratch(t, "snapshot-repo-template-");
|
|
457
|
+
const { snap, out } = cut(t, renderWithUnset(path, worktree), { env: { ...ENV, GIT_TEMPLATE_DIR: emptyTemplate } });
|
|
458
|
+
|
|
459
|
+
assert.match(out, /SNAPSHOT_TREE_MATCH/, `an ambient GIT_TEMPLATE_DIR must not stop the init from settling the tree: ${out}`);
|
|
460
|
+
assert.ok(
|
|
461
|
+
existsSync(join(snap, ".git", "info", "exclude")),
|
|
462
|
+
"an ambient GIT_TEMPLATE_DIR without info/ leaves the exclude file missing — node_modules is untracked but not excluded",
|
|
463
|
+
);
|
|
464
|
+
assert.equal(
|
|
465
|
+
git(snap, "status", "--porcelain", "--untracked-files=all"),
|
|
466
|
+
"",
|
|
467
|
+
"an ambient GIT_TEMPLATE_DIR left the snapshot reading dirty",
|
|
468
|
+
);
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
// #1083's remaining half, executed. #1129 gave every run its own root and
|
|
472
|
+
// said in the same breath that nothing removes it; this is the line that
|
|
473
|
+
// does, and every fixture below kills one distinct mutant of it:
|
|
474
|
+
//
|
|
475
|
+
// the line DELETED -> `run-staleaa` survives
|
|
476
|
+
// `-mtime +7` dropped -> `run-recentb` is deleted
|
|
477
|
+
// `-maxdepth 1` dropped -> the nested `run-` under a LIVE root goes
|
|
478
|
+
// `-name 'run-*'` dropped -> `snapshot-keep-me` goes
|
|
479
|
+
// `-type d` dropped -> the stale FILE goes
|
|
480
|
+
//
|
|
481
|
+
// Nine days and five, rather than one age and a fresh directory: the pair
|
|
482
|
+
// BRACKETS the cutoff, so widening it to a decade (a prune that never fires
|
|
483
|
+
// again) reds on the nine-day root and tightening it to a day reds on the
|
|
484
|
+
// five-day one. A fresh directory would pin neither, and this run's OWN root
|
|
485
|
+
// is excluded by the same gate the five-day fixture measures, at four orders
|
|
486
|
+
// of magnitude more margin — `mktemp -d` creates it milliseconds earlier —
|
|
487
|
+
// so it is not a sixth fixture here.
|
|
488
|
+
test(`${name}: the prune takes run roots nothing has touched for a week and leaves every other entry standing`, (t) => {
|
|
489
|
+
const parent = join(scratch(t, "snapshot-repo-prune-"), "pr7");
|
|
490
|
+
const stale = join(parent, "run-staleaa");
|
|
491
|
+
const recent = join(parent, "run-recentb");
|
|
492
|
+
const nested = join(recent, "verify-types", "run-nestedc");
|
|
493
|
+
const foreign = join(parent, "snapshot-keep-me");
|
|
494
|
+
const staleFile = join(parent, "run-stalefile");
|
|
495
|
+
|
|
496
|
+
mkdirSync(nested, { recursive: true });
|
|
497
|
+
mkdirSync(stale, { recursive: true });
|
|
498
|
+
mkdirSync(foreign, { recursive: true });
|
|
499
|
+
writeFileSync(staleFile, "");
|
|
500
|
+
// Deepest first. Creating a child sets its parent's mtime to now, so
|
|
501
|
+
// `recent` has to be aged after `nested` exists or the fixture ages nothing
|
|
502
|
+
// and the depth assertion below passes vacuously.
|
|
503
|
+
const age = (p, days) => {
|
|
504
|
+
const when = (Date.now() - days * DAY) / 1000;
|
|
505
|
+
utimesSync(p, when, when);
|
|
506
|
+
};
|
|
507
|
+
age(nested, 9);
|
|
508
|
+
age(stale, 9);
|
|
509
|
+
age(foreign, 9);
|
|
510
|
+
age(staleFile, 9);
|
|
511
|
+
age(recent, 5);
|
|
512
|
+
|
|
513
|
+
const r = spawnSync("sh", ["-c", renderPrune(path, parent)], { env: ENV, encoding: "utf8" });
|
|
514
|
+
|
|
515
|
+
assert.equal(r.status, 0, `the prune exited non-zero on a healthy per-PR parent: ${r.stderr}`);
|
|
516
|
+
assert.doesNotMatch(
|
|
517
|
+
r.stdout ?? "",
|
|
518
|
+
/SNAPSHOT_PRUNE_FAILED/,
|
|
519
|
+
`the prune named a failure on a parent it could read and write: ${r.stderr}`,
|
|
520
|
+
);
|
|
521
|
+
|
|
522
|
+
assert.ok(
|
|
523
|
+
!existsSync(stale),
|
|
524
|
+
"a run root nothing has touched for nine days survived the prune — #1083's growth half is back and the tree grows without bound",
|
|
525
|
+
);
|
|
526
|
+
assert.ok(
|
|
527
|
+
existsSync(recent),
|
|
528
|
+
"a five-day-old run root was removed — a fix-applier outlives the review that produced its findings and reads absolute paths into that tree (#1129), which is the trade that ticket refused",
|
|
529
|
+
);
|
|
530
|
+
assert.ok(
|
|
531
|
+
existsSync(nested),
|
|
532
|
+
"the prune descended into a live run root and took a refuter's own `run-`-named fixture with it — the depth bound is gone, so the prune now reaches inside trees it must not touch",
|
|
533
|
+
);
|
|
534
|
+
assert.ok(
|
|
535
|
+
existsSync(foreign),
|
|
536
|
+
"the prune removed an entry outside the `run-` namespace this script mints — its blast radius is no longer the roots it owns, and the per-PR parent holds whatever the caller put there",
|
|
537
|
+
);
|
|
538
|
+
assert.ok(
|
|
539
|
+
existsSync(staleFile),
|
|
540
|
+
"the prune removed a stale FILE named like a run root — a run root is a directory `mktemp -d` created, and `-type d` is what says so",
|
|
541
|
+
);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
// #1616. The ref-head operand, measured where it is PRODUCED rather than
|
|
545
|
+
// where it is consumed — the two guards that compare against it were never
|
|
546
|
+
// the defect, and this ticket changed neither. Six shapes, because the
|
|
547
|
+
// class is neither the fork/same-repo binary it first reads as, nor the
|
|
548
|
+
// resolves/resolves-nowhere binary the original fallback assumed: a
|
|
549
|
+
// same-repo PR, whose branch ref resolves; a cross-repo PR whose branch
|
|
550
|
+
// NAME collides with an unrelated branch `origin` already carries (this
|
|
551
|
+
// fix's own target — the old empty-triggered fallback let that collision
|
|
552
|
+
// silently answer with the wrong repository's commit); a cross-repo PR
|
|
553
|
+
// whose branch simply resolves nowhere, the ordinary case; a same-repo PR
|
|
554
|
+
// whose branch ref resolves nowhere (a branch since deleted on `origin`,
|
|
555
|
+
// unrelated to crossRepo); a PR where neither ref answers; and an origin
|
|
556
|
+
// that cannot be reached at all. The last two are the accept-on-absent path
|
|
557
|
+
// this ticket deliberately left alone, pinned here so "the fallback fires"
|
|
558
|
+
// cannot quietly become "something is always reported".
|
|
559
|
+
test(`${name}: a PR whose branch ref resolves reports it, and never reads the PR ref`, (t) => {
|
|
560
|
+
const { worktree, branchSha, pullSha } = remoteFixture(t);
|
|
561
|
+
const bin = tracingGit(t);
|
|
562
|
+
const r = readRef(renderRefs(path, worktree, PR), bin.dir);
|
|
563
|
+
|
|
564
|
+
assert.equal(r.status, 0, `the reads exited non-zero against a healthy origin: ${r.err}`);
|
|
565
|
+
assert.equal(
|
|
566
|
+
r.out,
|
|
567
|
+
branchSha,
|
|
568
|
+
"a same-repo PR no longer reports the branch ref — #1513 chose that operand and the fallback was not allowed to move it",
|
|
569
|
+
);
|
|
570
|
+
const reads = bin.reads();
|
|
571
|
+
assert.equal(
|
|
572
|
+
reads.length,
|
|
573
|
+
1,
|
|
574
|
+
`a PR whose branch ref answered paid ${reads.length} ref reads instead of 1 — the fallback is either unguarded or runs first, and every same-repo review now pays a second network round-trip: ${reads.join(" | ")}`,
|
|
575
|
+
);
|
|
576
|
+
assert.match(reads[0], /refs\/heads\//, `the one read was not the branch ref: ${reads[0]}`);
|
|
577
|
+
});
|
|
578
|
+
|
|
579
|
+
// #1616's actual defect, reproduced directly: `isCrossRepository` was never
|
|
580
|
+
// read, so a fork PR whose branch happens to share a NAME with something
|
|
581
|
+
// `origin` can already resolve — a real base-repo branch, not a
|
|
582
|
+
// hypothetical — silently answered with THAT commit instead of the fork's
|
|
583
|
+
// own head. GitHub does not require a fork's branch name to be unique
|
|
584
|
+
// against the base repository, so this fixture (the SAME one the accept
|
|
585
|
+
// test above uses — `refs/heads/<branch>` on `origin` carrying an unrelated
|
|
586
|
+
// commit, plus the base repo's own copy of the fork's real head under
|
|
587
|
+
// `refs/pull/<pr>/head`) is exactly what a colliding fork PR looks like on
|
|
588
|
+
// the base repo's remote, not a contrived edge case.
|
|
589
|
+
test(`${name}: a cross-repo PR whose branch collides with a base-repo branch reports the PR's own head, never the collision`, (t) => {
|
|
590
|
+
const { worktree, branchSha, pullSha } = remoteFixture(t);
|
|
591
|
+
const bin = tracingGit(t);
|
|
592
|
+
const r = readRef(renderRefs(path, worktree, PR), bin.dir, BRANCH, "true");
|
|
593
|
+
|
|
594
|
+
assert.equal(r.status, 0, `the reads exited non-zero against a colliding origin: ${r.err}`);
|
|
595
|
+
assert.notEqual(
|
|
596
|
+
r.out,
|
|
597
|
+
branchSha,
|
|
598
|
+
"a cross-repo PR reported the base repo's same-named branch instead of its own head — the collision this ticket exists to close",
|
|
599
|
+
);
|
|
600
|
+
assert.equal(r.out, pullSha, "a cross-repo PR did not report its own head from refs/pull/<pr>/head");
|
|
601
|
+
const reads = bin.reads();
|
|
602
|
+
assert.equal(
|
|
603
|
+
reads.length,
|
|
604
|
+
1,
|
|
605
|
+
`a cross-repo PR paid ${reads.length} ref reads instead of 1 — the branch-ref read must not run at all once the PR is cross-repo, colliding name or not: ${reads.join(" | ")}`,
|
|
606
|
+
);
|
|
607
|
+
assert.match(reads[0], new RegExp(`refs/pull/${PR}/head`), `the one read was not the PR's own ref on the base repo: ${reads[0]}`);
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
// The ordinary fork, no collision: `refs/heads/<branch>` does not exist on
|
|
611
|
+
// `origin` at all. `isCrossRepository` gates on the repository relationship,
|
|
612
|
+
// not on whether a collision happens to be present, so this case must also
|
|
613
|
+
// skip the branch-ref read entirely rather than attempt-then-fall-back.
|
|
614
|
+
test(`${name}: a cross-repo PR with no colliding branch skips the branch-ref read entirely`, (t) => {
|
|
615
|
+
const { worktree, pullSha } = remoteFixture(t, { branchRef: false });
|
|
616
|
+
const bin = tracingGit(t);
|
|
617
|
+
const r = readRef(renderRefs(path, worktree, PR), bin.dir, BRANCH, "true");
|
|
618
|
+
|
|
619
|
+
assert.equal(r.status, 0, `the reads exited non-zero against a fork-shaped origin: ${r.err}`);
|
|
620
|
+
assert.equal(r.out, pullSha, "a cross-repo PR did not report its own head from refs/pull/<pr>/head");
|
|
621
|
+
const reads = bin.reads();
|
|
622
|
+
assert.equal(
|
|
623
|
+
reads.length,
|
|
624
|
+
1,
|
|
625
|
+
`a cross-repo PR paid ${reads.length} ref reads instead of 1 — the branch-ref read must not even be attempted once the PR is cross-repo: ${reads.join(" | ")}`,
|
|
626
|
+
);
|
|
627
|
+
assert.match(reads[0], new RegExp(`refs/pull/${PR}/head`), `the one read was not the PR's own ref on the base repo: ${reads[0]}`);
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
// The residual empty-triggered fallback, unrelated to crossRepo: a
|
|
631
|
+
// same-repo PR (`isCrossRepository` false) whose branch was deleted on
|
|
632
|
+
// `origin` after the PR opened. This is the shape the ORIGINAL #1616 fix
|
|
633
|
+
// covered and this ticket's own fix must not have narrowed.
|
|
634
|
+
test(`${name}: a same-repo PR whose branch ref resolves nowhere falls back to the PR's own ref on the base repo`, (t) => {
|
|
635
|
+
const { worktree, pullSha } = remoteFixture(t, { branchRef: false });
|
|
636
|
+
const bin = tracingGit(t);
|
|
637
|
+
const r = readRef(renderRefs(path, worktree, PR), bin.dir);
|
|
638
|
+
|
|
639
|
+
assert.equal(r.status, 0, `the reads exited non-zero against a fork-shaped origin: ${r.err}`);
|
|
640
|
+
assert.equal(
|
|
641
|
+
r.out,
|
|
642
|
+
pullSha,
|
|
643
|
+
"a same-repo PR whose branch ref resolves nowhere still reports no ref head — the operand stays permanently absent and the wrong-commit backstop cannot fire",
|
|
644
|
+
);
|
|
645
|
+
const reads = bin.reads();
|
|
646
|
+
assert.equal(reads.length, 2, `expected the branch read and then the PR-ref read, got: ${reads.join(" | ")}`);
|
|
647
|
+
assert.match(reads[0], /refs\/heads\//, `the branch ref was not read FIRST: ${reads[0]}`);
|
|
648
|
+
assert.match(reads[1], new RegExp(`refs/pull/${PR}/head`), `the fallback did not read the PR's own ref on the base repo: ${reads[1]}`);
|
|
649
|
+
});
|
|
650
|
+
|
|
651
|
+
test(`${name}: neither ref resolving reports nothing, and does not fail the cut`, (t) => {
|
|
652
|
+
const { worktree } = remoteFixture(t, { branchRef: false, pullRef: false });
|
|
653
|
+
const r = readRef(renderRefs(path, worktree, PR), tracingGit(t).dir);
|
|
654
|
+
|
|
655
|
+
assert.equal(r.out, "", `a PR neither ref names reported something as its ref head: ${r.out}`);
|
|
656
|
+
assert.equal(r.status, 0, `the reads exited non-zero with both refs absent: ${r.err}`);
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
// The reason the compares treat an absent operand as "no opinion" in the
|
|
660
|
+
// first place, and the one this ticket must not have turned into a refusal:
|
|
661
|
+
// an unreachable origin has to come back empty, never as a value and never as
|
|
662
|
+
// a non-zero exit the snapshot agent reads as a failed cut.
|
|
663
|
+
test(`${name}: an unreachable origin reports nothing rather than failing the cut`, (t) => {
|
|
664
|
+
const worktree = scratch(t, "snapshot-refs-wt-");
|
|
665
|
+
git(worktree, "init", "-q");
|
|
666
|
+
git(worktree, "remote", "add", "origin", join(worktree, "no-such-remote.git"));
|
|
667
|
+
const r = readRef(renderRefs(path, worktree, PR), tracingGit(t).dir);
|
|
668
|
+
|
|
669
|
+
assert.equal(r.out, "", `a failed read put a value in the operand: ${r.out}`);
|
|
670
|
+
assert.equal(
|
|
671
|
+
r.status,
|
|
672
|
+
0,
|
|
673
|
+
"a failed ref read exits non-zero out of the block — an unreachable origin now cancels a runnable review instead of skipping the compare",
|
|
674
|
+
);
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
// `environmentNote`'s two regimes, read as a consumer reads them.
|
|
679
|
+
test("environmentNote says a verified snapshot measures the tree, and an unverified one does not", () => {
|
|
680
|
+
const verified = environmentNote({ repoVerified: true });
|
|
681
|
+
assert.doesNotMatch(verified, /UNVERIFIED/, "a verified environment is reported as unverified — every run now reads as degraded, and a reader who sees that on healthy runs stops reading it");
|
|
682
|
+
// `phrase()`, not a literal: this prose is hard-wrapped at ~78 columns, so
|
|
683
|
+
// every inter-word gap in it may be a newline, and a pin that reds on a
|
|
684
|
+
// rewrap is one the next reader edits around.
|
|
685
|
+
assert.match(verified, phrase("what a checkout at that commit does"), "the verified branch no longer says the suite measures what a checkout does, which is the whole claim the tree-hash compare buys");
|
|
686
|
+
|
|
687
|
+
const failed = environmentNote({ repoVerified: false, repoError: "SNAPSHOT_INIT_FAILED" });
|
|
688
|
+
assert.match(failed, /UNVERIFIED/, "a degraded environment is not announced");
|
|
689
|
+
assert.match(failed, /SNAPSHOT_INIT_FAILED/, "the reason is dropped — the payload says the environment differs without saying why, which is what a reader needs to tell an artifact from a regression");
|
|
690
|
+
assert.match(failed, phrase("NOT a validation of the tree"), "the consequence is dropped — a reader is left to infer that the counts mean less than they look like");
|
|
691
|
+
|
|
692
|
+
// Absent, not false: an agent that omitted the field must not read as a
|
|
693
|
+
// verified environment. The schema's `required` is what should prevent it;
|
|
694
|
+
// this is the same belt-and-braces `snapshotMissing` applies to
|
|
695
|
+
// `pathVerified`, at the layer that has to be right if that one is bypassed.
|
|
696
|
+
assert.match(environmentNote({}), /UNVERIFIED/, "an omitted repoVerified reads as a verified environment");
|
|
697
|
+
assert.match(environmentNote(null), /UNVERIFIED/, "a dead snapshot agent reads as a verified environment");
|
|
698
|
+
// A string is not a boolean: `=== true` is deliberate, since a schema bypass
|
|
699
|
+
// or a hand-built fixture can carry the word rather than the value.
|
|
700
|
+
assert.match(environmentNote({ repoVerified: "true" }), /UNVERIFIED/, "a non-boolean truthy value reads as a verified environment");
|
|
701
|
+
|
|
702
|
+
// #1056 Finding 5: SNAPSHOT_TREE_MISMATCH means the init SUCCEEDED — the
|
|
703
|
+
// snapshot IS a git repository, just not one holding the reviewed tree —
|
|
704
|
+
// which is a different cause than SNAPSHOT_INIT_FAILED (no repository at
|
|
705
|
+
// all). Repo-gated tests behave differently under it: they actually RUN
|
|
706
|
+
// there, so a failure is a real measurement of a DIFFERENT tree, not the
|
|
707
|
+
// "every test that needs one skips or fails" story the init-failed case
|
|
708
|
+
// tells.
|
|
709
|
+
const mismatched = environmentNote({ repoVerified: false, repoError: "SNAPSHOT_TREE_MISMATCH=snapshot aaa vs commit bbb" });
|
|
710
|
+
assert.match(mismatched, /UNVERIFIED/, "a mismatched tree is not announced as degraded");
|
|
711
|
+
assert.match(mismatched, /SNAPSHOT_TREE_MISMATCH=snapshot aaa vs commit bbb/, "the mismatch reason is dropped — a reader cannot tell which tree was measured");
|
|
712
|
+
assert.match(mismatched, phrase("the snapshot IS a git repository"), "the mismatch case no longer says the init succeeded — it reads as no repository at all, which is the wrong cause");
|
|
713
|
+
assert.doesNotMatch(
|
|
714
|
+
mismatched,
|
|
715
|
+
phrase("NOT a validation of the tree"),
|
|
716
|
+
"the mismatch case still carries the init-failed consequence, which claims repo-gated tests skip or fail there when they actually RUN against the wrong tree",
|
|
717
|
+
);
|
|
718
|
+
});
|
|
719
|
+
|
|
720
|
+
// The snapshot is handed a node_modules symlink AFTER its commit, so it is
|
|
721
|
+
// untracked by construction — and an untracked entry makes every `git status`
|
|
722
|
+
// in the snapshot read dirty, which is the one signal that would otherwise say
|
|
723
|
+
// "this tree is exactly the reviewed commit". Excluded rather than committed:
|
|
724
|
+
// in the index it would change the tree hash the verification rests on.
|
|
725
|
+
test("a snapshot carrying the node_modules symlink still reads clean", (t) => {
|
|
726
|
+
const worktree = reviewedRepo(t);
|
|
727
|
+
const modules = join(worktree, "node_modules");
|
|
728
|
+
mkdirSync(modules, { recursive: true });
|
|
729
|
+
writeFileSync(join(modules, "marker"), "");
|
|
730
|
+
const { snap, out } = cut(t, render(SOURCES[0][1], worktree));
|
|
731
|
+
|
|
732
|
+
assert.match(out, /SNAPSHOT_TREE_MATCH/, `the fixture's own cut failed: ${out}`);
|
|
733
|
+
assert.ok(existsSync(join(snap, "node_modules", "marker")), "the symlink is missing — a derived `npm test --` cannot run in there");
|
|
734
|
+
assert.equal(
|
|
735
|
+
git(snap, "status", "--porcelain", "--untracked-files=all"),
|
|
736
|
+
"",
|
|
737
|
+
"the snapshot reads dirty — the symlink is neither excluded nor committed, so `git status` there no longer says the tree is the reviewed commit",
|
|
738
|
+
);
|
|
739
|
+
// And it is NOT tracked: committed instead of excluded, the tree hash would
|
|
740
|
+
// stop matching the reviewed commit's and every review would report a
|
|
741
|
+
// mismatch it cannot act on.
|
|
742
|
+
assert.equal(
|
|
743
|
+
spawnSync("git", ["-C", snap, "ls-files", "--error-unmatch", "node_modules"], { env: ENV, encoding: "utf8" }).status !== 0,
|
|
744
|
+
true,
|
|
745
|
+
"node_modules is tracked in the snapshot — the tree hash cannot match the reviewed commit's",
|
|
746
|
+
);
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
// The symlink the test above needs is created by the block's last line, whose
|
|
750
|
+
// own guard is pinned as text elsewhere. This asserts the fixture actually
|
|
751
|
+
// exercised that line rather than passing because nothing made a symlink.
|
|
752
|
+
test("the block only symlinks node_modules where the reviewed tree has one", (t) => {
|
|
753
|
+
const worktree = reviewedRepo(t);
|
|
754
|
+
const { snap } = cut(t, render(SOURCES[0][1], worktree));
|
|
755
|
+
// `existsSync` resolves through a symlink, so a mutation that bypasses the
|
|
756
|
+
// `-d ${worktree}/node_modules` guard by producing a DANGLING symlink at
|
|
757
|
+
// this path would still read as "nothing here" and pass silently.
|
|
758
|
+
// `lstatSync` inspects the entry itself, dangling or not.
|
|
759
|
+
let entry = true;
|
|
760
|
+
try {
|
|
761
|
+
lstatSync(join(snap, "node_modules"));
|
|
762
|
+
} catch {
|
|
763
|
+
entry = false;
|
|
764
|
+
}
|
|
765
|
+
assert.ok(!entry, "a snapshot of a repo with no node_modules carries one anyway — the guard on the symlink is gone");
|
|
766
|
+
assert.ok(existsSync(join(snap, ".git", "info", "exclude")), "the exclude file is missing, so the clean-status property above rests on nothing");
|
|
767
|
+
assert.match(
|
|
768
|
+
readFileSync(join(snap, ".git", "info", "exclude"), "utf8"),
|
|
769
|
+
/^node_modules$/m,
|
|
770
|
+
"node_modules is no longer excluded in the snapshot's own repository",
|
|
771
|
+
);
|
|
772
|
+
});
|