@aviaratech/ai-delivery 0.3.35 → 0.3.36
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/CONTRIBUTING.md +12 -206
- package/README.md +57 -554
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1651 -1590
- package/dist/boardReconcile.test.js.map +7 -1
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +402 -515
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -45
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +424 -369
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +288 -14
- package/dist/config/deliveryConfig.js +472 -390
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +773 -649
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -479
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +16 -11
- package/dist/dispatch.js +329 -353
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +103 -96
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +59 -19
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.js +73 -67
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +44 -52
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +1 -0
- package/dist/github/discovery.js +197 -215
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +18 -2
- package/dist/github/projectDelivery.js +615 -557
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.js +433 -389
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +40 -9
- package/dist/issue.js +2102 -1742
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +989 -885
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1945 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1059 -989
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -94
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +264 -286
- package/dist/mcp/tools.js +267 -340
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1229
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1842 -1423
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +460 -409
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +125 -125
- package/dist/services/boardReconcileService.js +1295 -1421
- package/dist/services/boardReconcileService.js.map +7 -1
- package/dist/services/deliveryAdmission.js +131 -154
- package/dist/services/deliveryAdmission.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +353 -352
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -19
- package/dist/verification.js +1020 -1939
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.js +23 -24
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +9 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
- package/plugins/ai-delivery/runtime/dist/cli.js +358 -115
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3329
- package/dist/setup.test.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
|
@@ -1,228 +1,430 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { execFileSync } from
|
|
3
|
-
import { createHash } from
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import {
|
|
5
|
+
chmodSync,
|
|
6
|
+
copyFileSync,
|
|
7
|
+
existsSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
mkdtempSync,
|
|
10
|
+
readFileSync,
|
|
11
|
+
rmSync,
|
|
12
|
+
symlinkSync,
|
|
13
|
+
writeFileSync
|
|
14
|
+
} from "node:fs";
|
|
15
|
+
import { tmpdir } from "node:os";
|
|
16
|
+
import { join, resolve } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
import { test } from "vitest";
|
|
19
|
+
const staged = await import(new URL("../scripts/pre-commit.mjs", import.meta.url).href);
|
|
20
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
11
21
|
function fixture(runner) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const base = mkdtempSync(join(tmpdir(), "staged-check-fixture-"));
|
|
23
|
+
const cwd = join(base, "repo");
|
|
24
|
+
mkdirSync(join(cwd, "scripts"), { recursive: true });
|
|
25
|
+
const git = (...args) => execFileSync("git", args, { cwd, encoding: "utf8" }).trim();
|
|
26
|
+
git("init", "-q");
|
|
27
|
+
git("config", "user.name", "Synthetic Contributor");
|
|
28
|
+
git("config", "user.email", "contributor@example.test");
|
|
29
|
+
writeFileSync(join(cwd, "partial.txt"), "original\n");
|
|
30
|
+
writeFileSync(join(cwd, "delete.txt"), "tracked deletion\n");
|
|
31
|
+
writeFileSync(join(cwd, ".gitignore"), "/node_modules/\n/dist/\n");
|
|
32
|
+
const manifest = { name: "staged-fixture", version: "1.0.0", dependencies: { "fixture-dependency": "1.0.0" } };
|
|
33
|
+
const packages = {
|
|
34
|
+
"": manifest,
|
|
35
|
+
"node_modules/fixture-dependency": { version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } },
|
|
36
|
+
"node_modules/fixture-transitive": { version: "1.0.0" }
|
|
37
|
+
};
|
|
38
|
+
writeFileSync(join(cwd, "package.json"), JSON.stringify(manifest));
|
|
39
|
+
writeFileSync(
|
|
40
|
+
join(cwd, "package-lock.json"),
|
|
41
|
+
JSON.stringify({ lockfileVersion: 3, synthetic: "original", packages })
|
|
42
|
+
);
|
|
43
|
+
mkdirSync(join(cwd, "src"));
|
|
44
|
+
writeFileSync(join(cwd, "src/selected.test.ts"), "// selected synthetic contract\n");
|
|
45
|
+
mkdirSync(join(cwd, "node_modules/fixture-dependency"), { recursive: true });
|
|
46
|
+
writeFileSync(
|
|
47
|
+
join(cwd, "node_modules/fixture-dependency/package.json"),
|
|
48
|
+
JSON.stringify({ name: "fixture-dependency", version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } })
|
|
49
|
+
);
|
|
50
|
+
writeFileSync(
|
|
51
|
+
join(cwd, "node_modules/.package-lock.json"),
|
|
52
|
+
JSON.stringify({
|
|
53
|
+
lockfileVersion: 3,
|
|
54
|
+
packages: {
|
|
55
|
+
"node_modules/fixture-dependency": { version: "1.0.0", dependencies: { "fixture-transitive": "1.0.0" } },
|
|
56
|
+
"node_modules/fixture-transitive": { version: "1.0.0" }
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
mkdirSync(join(cwd, "node_modules/fixture-transitive"));
|
|
61
|
+
writeFileSync(
|
|
62
|
+
join(cwd, "node_modules/fixture-transitive/package.json"),
|
|
63
|
+
JSON.stringify({ name: "fixture-transitive", version: "1.0.0" })
|
|
64
|
+
);
|
|
65
|
+
if (runner !== void 0) writeFileSync(join(cwd, "scripts/checks.mjs"), runner);
|
|
66
|
+
git("add", ".");
|
|
67
|
+
git("commit", "-qm", "Synthetic baseline");
|
|
68
|
+
return { cwd, base, git, cleanup: () => rmSync(base, { recursive: true, force: true }) };
|
|
27
69
|
}
|
|
28
|
-
test(
|
|
70
|
+
test(
|
|
71
|
+
"exact staged tree isolates partial edits, additions, deletions and lockfile changes without index/unstaged writes",
|
|
72
|
+
{ tags: ["release"] },
|
|
73
|
+
() => {
|
|
29
74
|
const f = fixture();
|
|
30
75
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
writeFileSync(join(f.cwd, "partial.txt"), "staged content\n");
|
|
77
|
+
writeFileSync(join(f.cwd, "added.txt"), "staged addition\n");
|
|
78
|
+
writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"staged lock"}\n');
|
|
79
|
+
f.git("rm", "-q", "delete.txt");
|
|
80
|
+
f.git("add", "partial.txt", "added.txt", "package-lock.json");
|
|
81
|
+
writeFileSync(join(f.cwd, "partial.txt"), "unstaged content must survive\n");
|
|
82
|
+
writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"unstaged lock"}\n');
|
|
83
|
+
writeFileSync(join(f.cwd, "delete.txt"), "unstaged recreated file\n");
|
|
84
|
+
writeFileSync(join(f.cwd, "untracked.txt"), "unrelated local file\n");
|
|
85
|
+
const index = join(f.cwd, ".git/index");
|
|
86
|
+
const before = hash(readFileSync(index));
|
|
87
|
+
const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, "snapshot-owner"));
|
|
88
|
+
assert.equal(readFileSync(join(snapshot.snapshot, "partial.txt"), "utf8"), "staged content\n");
|
|
89
|
+
assert.equal(readFileSync(join(snapshot.snapshot, "added.txt"), "utf8"), "staged addition\n");
|
|
90
|
+
assert.equal(readFileSync(join(snapshot.snapshot, "package-lock.json"), "utf8"), '{"synthetic":"staged lock"}\n');
|
|
91
|
+
assert.equal(existsSync(join(snapshot.snapshot, "delete.txt")), false);
|
|
92
|
+
assert.equal(existsSync(join(snapshot.snapshot, "untracked.txt")), false);
|
|
93
|
+
assert.equal(snapshot.originalIndexSha256, before);
|
|
94
|
+
assert.equal(hash(readFileSync(index)), before);
|
|
95
|
+
assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "unstaged content must survive\n");
|
|
96
|
+
assert.equal(readFileSync(join(f.cwd, "package-lock.json"), "utf8"), '{"synthetic":"unstaged lock"}\n');
|
|
97
|
+
assert.equal(readFileSync(join(f.cwd, "delete.txt"), "utf8"), "unstaged recreated file\n");
|
|
98
|
+
assert.equal(readFileSync(join(f.cwd, "untracked.txt"), "utf8"), "unrelated local file\n");
|
|
99
|
+
assert.match(snapshot.tree, /^[0-9a-f]{40}$/u);
|
|
100
|
+
} finally {
|
|
101
|
+
f.cleanup();
|
|
55
102
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
function syntheticRunner(fullSuccess = true) {
|
|
61
|
-
return `import fs from 'node:fs';import path from 'node:path';
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
function syntheticRunner(focused = true) {
|
|
106
|
+
return `import fs from 'node:fs';import path from 'node:path';
|
|
62
107
|
const args=process.argv.slice(2);const tree=args[args.indexOf('--staged-tree')+1],dir=args[args.indexOf('--results-dir')+1];
|
|
63
|
-
if(
|
|
64
|
-
if(fs.readFileSync('package-lock.json','utf8')!=='
|
|
108
|
+
if(args.includes('--install')||!args.includes('--fast')||!args.includes('--test-file'))process.exit(8);
|
|
109
|
+
if(JSON.parse(fs.readFileSync('package-lock.json','utf8')).synthetic!=='original')process.exit(9);
|
|
65
110
|
if(process.env.GH_TOKEN||process.env.NODE_OPTIONS||process.env.NODE_PATH)process.exit(10);
|
|
66
|
-
fs.mkdirSync(
|
|
111
|
+
fs.mkdirSync('node_modules/.vite',{recursive:true});fs.writeFileSync('node_modules/.vite/owned-cache','synthetic cache');
|
|
112
|
+
fs.mkdirSync(dir,{recursive:true});fs.writeFileSync(path.join(dir,'result.json'),JSON.stringify({scope:'${focused ? "focused" : "fast"}',status:'partial-passed',fullSuccess:false,artifactQualified:false,selectedTestFiles:['dist/selected.test.js'],tests:{files:1,total:1,passed:1},tree:{stagedGitTree:tree}}));`;
|
|
67
113
|
}
|
|
68
|
-
test(
|
|
114
|
+
test(
|
|
115
|
+
"missing explicit hook selection refuses before validation without provisioning dependencies",
|
|
116
|
+
{ tags: ["release"] },
|
|
117
|
+
async () => {
|
|
69
118
|
const f = fixture(syntheticRunner());
|
|
70
119
|
try {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
assert.equal(result.fullSuccess, true);
|
|
78
|
-
assert.equal(result.sourceIndexUnchanged, true);
|
|
79
|
-
assert.equal(result.cleanupConfirmed, true);
|
|
80
|
-
assert.equal(existsSync(result.ownedDirectory), false);
|
|
81
|
-
assert.equal(existsSync(join(resultsDir, 'full/result.json')), true);
|
|
82
|
-
assert.equal(hash(readFileSync(join(f.cwd, '.git/index'))), index);
|
|
83
|
-
assert.match(readFileSync(join(f.cwd, 'scripts/checks.mjs'), 'utf8'), /Unstaged runner/u);
|
|
84
|
-
assert.match(readFileSync(join(f.cwd, 'package-lock.json'), 'utf8'), /unstaged must not install/u);
|
|
85
|
-
await assert.rejects(staged.runStagedChecks({ cwd: f.cwd, resultsDir }), /Existing staged result/u);
|
|
120
|
+
const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir: join(f.base, "missing-selection") });
|
|
121
|
+
assert.equal(result.status, "failed");
|
|
122
|
+
assert.match(result.error, /explicit.*selection/iu);
|
|
123
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
124
|
+
} finally {
|
|
125
|
+
f.cleanup();
|
|
86
126
|
}
|
|
87
|
-
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
test(
|
|
130
|
+
"staged dependency incompatibility refuses instead of installing or accepting different package versions",
|
|
131
|
+
{ tags: ["release"] },
|
|
132
|
+
async () => {
|
|
133
|
+
for (const scenario of [
|
|
134
|
+
"version",
|
|
135
|
+
"package-version",
|
|
136
|
+
"missing",
|
|
137
|
+
"missing-transitive",
|
|
138
|
+
"missing-metadata-entry",
|
|
139
|
+
"staged-manifest"
|
|
140
|
+
]) {
|
|
141
|
+
const f = fixture(syntheticRunner());
|
|
142
|
+
try {
|
|
143
|
+
const metadata = join(f.cwd, "node_modules/.package-lock.json");
|
|
144
|
+
if (scenario === "missing") rmSync(join(f.cwd, "node_modules"), { recursive: true });
|
|
145
|
+
else if (scenario === "missing-transitive")
|
|
146
|
+
rmSync(join(f.cwd, "node_modules/fixture-transitive"), { recursive: true });
|
|
147
|
+
else if (scenario === "package-version")
|
|
148
|
+
writeFileSync(
|
|
149
|
+
join(f.cwd, "node_modules/fixture-transitive/package.json"),
|
|
150
|
+
JSON.stringify({ name: "fixture-transitive", version: "2.0.0" })
|
|
151
|
+
);
|
|
152
|
+
else if (scenario === "staged-manifest") {
|
|
153
|
+
writeFileSync(
|
|
154
|
+
join(f.cwd, "package.json"),
|
|
155
|
+
JSON.stringify({
|
|
156
|
+
name: "staged-fixture",
|
|
157
|
+
version: "1.0.0",
|
|
158
|
+
dependencies: { "fixture-dependency": "2.0.0" }
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
f.git("add", "package.json");
|
|
162
|
+
} else
|
|
163
|
+
writeFileSync(
|
|
164
|
+
metadata,
|
|
165
|
+
JSON.stringify({
|
|
166
|
+
lockfileVersion: 3,
|
|
167
|
+
packages: { "node_modules/fixture-dependency": { version: scenario === "version" ? "2.0.0" : "1.0.0" } }
|
|
168
|
+
})
|
|
169
|
+
);
|
|
170
|
+
const result = await staged.runStagedChecks({
|
|
171
|
+
cwd: f.cwd,
|
|
172
|
+
resultsDir: join(f.base, "incompatible"),
|
|
173
|
+
testFiles: ["dist/selected.test.js"]
|
|
174
|
+
});
|
|
175
|
+
assert.equal(result.status, "failed");
|
|
176
|
+
assert.match(result.error, /dependenc|compatible|setup/iu);
|
|
177
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
178
|
+
assert.equal(result.sourceIndexUnchanged, true);
|
|
179
|
+
} finally {
|
|
88
180
|
f.cleanup();
|
|
181
|
+
}
|
|
89
182
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
f.
|
|
105
|
-
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
test(
|
|
186
|
+
"observable installed dependency metadata drift cannot become successful hook evidence",
|
|
187
|
+
{ tags: ["release"] },
|
|
188
|
+
async () => {
|
|
189
|
+
for (const changedMetadata of [".package-lock.json", "fixture-transitive/package.json"]) {
|
|
190
|
+
const f = fixture(syntheticRunner());
|
|
191
|
+
try {
|
|
192
|
+
const result = await staged.runStagedChecks({
|
|
193
|
+
cwd: f.cwd,
|
|
194
|
+
resultsDir: join(f.base, "drift"),
|
|
195
|
+
testFiles: ["dist/selected.test.js"],
|
|
196
|
+
execute: async () => {
|
|
197
|
+
const metadata = join(f.cwd, "node_modules", changedMetadata);
|
|
198
|
+
writeFileSync(metadata, readFileSync(metadata, "utf8") + "\n");
|
|
199
|
+
return { status: "passed", cleanupConfirmed: true };
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
assert.equal(result.status, "failed");
|
|
203
|
+
assert.match(result.error, /dependenc.*(changed|drift)/iu);
|
|
204
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
205
|
+
} finally {
|
|
206
|
+
f.cleanup();
|
|
207
|
+
}
|
|
106
208
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
test(
|
|
212
|
+
"tracked entry reuses transitive dependencies with staged code and cleans only owned snapshot",
|
|
213
|
+
{ tags: ["release"] },
|
|
214
|
+
async () => {
|
|
109
215
|
const f = fixture(syntheticRunner());
|
|
110
216
|
try {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
217
|
+
writeFileSync(join(f.cwd, "scripts/checks.mjs"), "throw Error('Unstaged runner must not execute');\n");
|
|
218
|
+
writeFileSync(join(f.cwd, "package-lock.json"), '{"synthetic":"unstaged must not install"}\n');
|
|
219
|
+
writeFileSync(
|
|
220
|
+
join(f.cwd, "package.json"),
|
|
221
|
+
JSON.stringify({
|
|
222
|
+
name: "staged-fixture",
|
|
223
|
+
version: "1.0.0",
|
|
224
|
+
dependencies: { "fixture-dependency": "1.0.0" },
|
|
225
|
+
description: "unstaged manifest must survive"
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
const index = hash(readFileSync(join(f.cwd, ".git/index")));
|
|
229
|
+
const resultsDir = join(f.base, "results");
|
|
230
|
+
const result = await staged.runStagedChecks({ cwd: f.cwd, resultsDir, testFiles: ["dist/selected.test.js"] });
|
|
231
|
+
assert.equal(result.status, "partial-passed");
|
|
232
|
+
assert.equal(result.fullSuccess, false);
|
|
233
|
+
assert.equal(result.sourceIndexUnchanged, true);
|
|
234
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
235
|
+
assert.equal(existsSync(result.ownedDirectory), false);
|
|
236
|
+
assert.equal(existsSync(join(resultsDir, "focused/result.json")), true);
|
|
237
|
+
assert.equal(existsSync(join(f.cwd, "node_modules/.vite")), false);
|
|
238
|
+
assert.equal(
|
|
239
|
+
JSON.parse(readFileSync(join(f.cwd, "node_modules/fixture-dependency/package.json"), "utf8")).version,
|
|
240
|
+
"1.0.0"
|
|
241
|
+
);
|
|
242
|
+
assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), index);
|
|
243
|
+
assert.match(readFileSync(join(f.cwd, "scripts/checks.mjs"), "utf8"), /Unstaged runner/u);
|
|
244
|
+
assert.match(readFileSync(join(f.cwd, "package-lock.json"), "utf8"), /unstaged must not install/u);
|
|
245
|
+
assert.match(readFileSync(join(f.cwd, "package.json"), "utf8"), /unstaged manifest must survive/u);
|
|
246
|
+
await assert.rejects(staged.runStagedChecks({ cwd: f.cwd, resultsDir }), /Existing staged result/u);
|
|
247
|
+
} finally {
|
|
248
|
+
f.cleanup();
|
|
119
249
|
}
|
|
120
|
-
|
|
250
|
+
}
|
|
251
|
+
);
|
|
252
|
+
test(
|
|
253
|
+
"fast-only or missing staged runner cannot become focused hook success; unrelated source survives failure",
|
|
254
|
+
{ tags: ["release"] },
|
|
255
|
+
async () => {
|
|
256
|
+
for (const runner of [void 0, syntheticRunner(false)]) {
|
|
257
|
+
const f = fixture(runner);
|
|
258
|
+
try {
|
|
259
|
+
const before = hash(readFileSync(join(f.cwd, ".git/index")));
|
|
260
|
+
const result = await staged.runStagedChecks({
|
|
261
|
+
cwd: f.cwd,
|
|
262
|
+
resultsDir: join(f.base, "result"),
|
|
263
|
+
testFiles: ["dist/selected.test.js"]
|
|
264
|
+
});
|
|
265
|
+
assert.equal(result.fullSuccess, false);
|
|
266
|
+
assert.equal(result.status, "failed");
|
|
267
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
268
|
+
assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
|
|
269
|
+
assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "original\n");
|
|
270
|
+
} finally {
|
|
121
271
|
f.cleanup();
|
|
272
|
+
}
|
|
122
273
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
274
|
+
}
|
|
275
|
+
);
|
|
276
|
+
test(
|
|
277
|
+
"unsafe staged symlink is refused before commands and cleanup preserves the source index",
|
|
278
|
+
{ tags: ["release"] },
|
|
279
|
+
async () => {
|
|
280
|
+
const f = fixture(syntheticRunner());
|
|
281
|
+
try {
|
|
282
|
+
symlinkSync("../outside", join(f.cwd, "link"));
|
|
283
|
+
f.git("add", "link");
|
|
284
|
+
const before = hash(readFileSync(join(f.cwd, ".git/index")));
|
|
285
|
+
const result = await staged.runStagedChecks({
|
|
286
|
+
cwd: f.cwd,
|
|
287
|
+
resultsDir: join(f.base, "result"),
|
|
288
|
+
testFiles: ["dist/selected.test.js"]
|
|
289
|
+
});
|
|
290
|
+
assert.equal(result.status, "failed");
|
|
291
|
+
assert.match(result.error, /symlink index entry/u);
|
|
292
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
293
|
+
assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
|
|
294
|
+
} finally {
|
|
295
|
+
f.cleanup();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
test(
|
|
300
|
+
"staged graph cancellation preserves source and partial evidence after owned child cleanup",
|
|
301
|
+
{ tags: ["release"] },
|
|
302
|
+
async () => {
|
|
125
303
|
const f = fixture("console.log('synthetic staged graph started');setInterval(()=>{},1000);\n");
|
|
126
304
|
const controller = new AbortController();
|
|
127
305
|
const timer = setTimeout(() => controller.abort(), 750);
|
|
128
306
|
try {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
307
|
+
const before = hash(readFileSync(join(f.cwd, ".git/index")));
|
|
308
|
+
const resultsDir = join(f.base, "result");
|
|
309
|
+
const result = await staged.runStagedChecks({
|
|
310
|
+
cwd: f.cwd,
|
|
311
|
+
resultsDir,
|
|
312
|
+
signal: controller.signal,
|
|
313
|
+
testFiles: ["dist/selected.test.js"]
|
|
314
|
+
});
|
|
315
|
+
assert.equal(result.status, "cancelled");
|
|
316
|
+
assert.equal(result.exitCode, 130);
|
|
317
|
+
assert.equal(result.sourceIndexUnchanged, true);
|
|
318
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
319
|
+
assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
|
|
320
|
+
assert.match(readFileSync(join(resultsDir, "process/stdout.txt"), "utf8"), /synthetic staged graph started/u);
|
|
321
|
+
} finally {
|
|
322
|
+
clearTimeout(timer);
|
|
323
|
+
f.cleanup();
|
|
142
324
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
325
|
+
}
|
|
326
|
+
);
|
|
327
|
+
test(
|
|
328
|
+
"unconfirmed child completion preserves the owned snapshot and marks cleanup unproved",
|
|
329
|
+
{ tags: ["release"] },
|
|
330
|
+
async () => {
|
|
145
331
|
const f = fixture(syntheticRunner());
|
|
146
332
|
let ownedDirectory;
|
|
147
333
|
try {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
334
|
+
const before = hash(readFileSync(join(f.cwd, ".git/index")));
|
|
335
|
+
const result = await staged.runStagedChecks({
|
|
336
|
+
cwd: f.cwd,
|
|
337
|
+
resultsDir: join(f.base, "uncertain"),
|
|
338
|
+
testFiles: ["dist/selected.test.js"],
|
|
339
|
+
execute: async () => ({ status: "failed", cleanupConfirmed: false })
|
|
340
|
+
});
|
|
341
|
+
ownedDirectory = result.ownedDirectory;
|
|
342
|
+
assert.equal(result.fullSuccess, false);
|
|
343
|
+
assert.equal(result.cleanupConfirmed, false);
|
|
344
|
+
assert.equal(existsSync(ownedDirectory), true);
|
|
345
|
+
assert.match(result.error, /quiescence is unconfirmed/u);
|
|
346
|
+
assert.equal(hash(readFileSync(join(f.cwd, ".git/index"))), before);
|
|
347
|
+
} finally {
|
|
348
|
+
if (ownedDirectory) rmSync(ownedDirectory, { recursive: true, force: true });
|
|
349
|
+
f.cleanup();
|
|
160
350
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
test('caller relative alternate index supplies the exact tree and preserves both indexes and unstaged bytes', () => {
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
test(
|
|
354
|
+
"caller relative alternate index supplies the exact tree and preserves both indexes and unstaged bytes",
|
|
355
|
+
{ tags: ["release"] },
|
|
356
|
+
() => {
|
|
169
357
|
const f = fixture();
|
|
170
358
|
const previous = process.env.GIT_INDEX_FILE;
|
|
171
359
|
try {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
360
|
+
const primary = join(f.cwd, ".git/index");
|
|
361
|
+
const alternate = join(f.cwd, ".git/alternate-index");
|
|
362
|
+
writeFileSync(join(f.cwd, "partial.txt"), "primary staged\n");
|
|
363
|
+
f.git("add", "partial.txt");
|
|
364
|
+
copyFileSync(primary, alternate);
|
|
365
|
+
writeFileSync(join(f.cwd, "partial.txt"), "alternate staged\n");
|
|
366
|
+
execFileSync("git", ["add", "partial.txt"], { cwd: f.cwd, env: { ...process.env, GIT_INDEX_FILE: alternate } });
|
|
367
|
+
writeFileSync(join(f.cwd, "partial.txt"), "final unstaged bytes\n");
|
|
368
|
+
const primaryHash = hash(readFileSync(primary)), alternateHash = hash(readFileSync(alternate));
|
|
369
|
+
assert.notEqual(primaryHash, alternateHash);
|
|
370
|
+
process.env.GIT_INDEX_FILE = ".git/alternate-index";
|
|
371
|
+
const snapshot = staged.prepareStagedSnapshot(f.cwd, join(f.base, "alternate-snapshot"));
|
|
372
|
+
assert.equal(snapshot.index, alternate);
|
|
373
|
+
assert.equal(snapshot.originalIndexSha256, alternateHash);
|
|
374
|
+
assert.equal(readFileSync(join(snapshot.snapshot, "partial.txt"), "utf8"), "alternate staged\n");
|
|
375
|
+
assert.equal(hash(readFileSync(primary)), primaryHash);
|
|
376
|
+
assert.equal(hash(readFileSync(alternate)), alternateHash);
|
|
377
|
+
assert.equal(readFileSync(join(f.cwd, "partial.txt"), "utf8"), "final unstaged bytes\n");
|
|
378
|
+
} finally {
|
|
379
|
+
if (previous === void 0) delete process.env.GIT_INDEX_FILE;
|
|
380
|
+
else process.env.GIT_INDEX_FILE = previous;
|
|
381
|
+
f.cleanup();
|
|
190
382
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
test('synthetic commit -a and path-limited hooks validate the Git-supplied temporary commit index', () => {
|
|
200
|
-
const entry = fileURLToPath(new URL('../scripts/pre-commit.mjs', import.meta.url));
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
test(
|
|
386
|
+
"synthetic commit -a and path-limited hooks validate the Git-supplied temporary commit index",
|
|
387
|
+
{ tags: ["release"] },
|
|
388
|
+
() => {
|
|
389
|
+
const entry = fileURLToPath(new URL("../scripts/pre-commit.mjs", import.meta.url));
|
|
201
390
|
const quote = (value) => "'" + value.replaceAll("'", "'\\''") + "'";
|
|
202
|
-
for (const mode of [
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
391
|
+
for (const mode of ["all", "path"]) {
|
|
392
|
+
const f = fixture(syntheticRunner());
|
|
393
|
+
try {
|
|
394
|
+
const resultsDir = join(f.base, "hook-results");
|
|
395
|
+
const hook = join(f.cwd, ".git/hooks/pre-commit");
|
|
396
|
+
writeFileSync(
|
|
397
|
+
hook,
|
|
398
|
+
`#!/bin/sh
|
|
399
|
+
exec ${quote(process.execPath)} ${quote(entry)} --results-dir ${quote(resultsDir)}${mode === "path" ? " --test-file dist/selected.test.js" : ""}
|
|
400
|
+
`
|
|
401
|
+
);
|
|
402
|
+
chmodSync(hook, 493);
|
|
403
|
+
writeFileSync(join(f.cwd, "partial.txt"), `${mode} committed content
|
|
404
|
+
`);
|
|
405
|
+
if (mode === "path") writeFileSync(join(f.cwd, "delete.txt"), "unrelated unstaged content\n");
|
|
406
|
+
execFileSync(
|
|
407
|
+
"git",
|
|
408
|
+
["commit", "-qm", `Synthetic ${mode} commit`, ...mode === "all" ? ["-a"] : ["--", "partial.txt"]],
|
|
409
|
+
{
|
|
410
|
+
cwd: f.cwd,
|
|
411
|
+
env: { ...process.env, AI_DELIVERY_FOCUSED_TESTS: '["dist/selected.test.js"]' }
|
|
412
|
+
}
|
|
413
|
+
);
|
|
414
|
+
const result = JSON.parse(readFileSync(join(resultsDir, "staged.json"), "utf8"));
|
|
415
|
+
assert.equal(result.fullSuccess, false);
|
|
416
|
+
assert.equal(result.status, "partial-passed");
|
|
417
|
+
assert.equal(result.sourceIndexUnchanged, true);
|
|
418
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
419
|
+
assert.notEqual(resolve(result.sourceIndexPath), join(f.cwd, ".git/index"));
|
|
420
|
+
assert.equal(result.stagedTree, f.git("rev-parse", "HEAD^{tree}"));
|
|
421
|
+
assert.equal(f.git("show", "HEAD:partial.txt"), `${mode} committed content`);
|
|
422
|
+
if (mode === "path")
|
|
423
|
+
assert.equal(readFileSync(join(f.cwd, "delete.txt"), "utf8"), "unrelated unstaged content\n");
|
|
424
|
+
} finally {
|
|
425
|
+
f.cleanup();
|
|
426
|
+
}
|
|
226
427
|
}
|
|
227
|
-
}
|
|
228
|
-
|
|
428
|
+
}
|
|
429
|
+
);
|
|
430
|
+
//# sourceMappingURL=stagedChecks.test.js.map
|