Skip to content

Commit dbe71fd

Browse files
committed
test(sdk): 隔离版本测试的 Git hook 环境
1 parent 46c6d95 commit dbe71fd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/sdk/tests/unit/project-versions.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,19 @@ describe("shared project versions", () => {
6767
test("keeps the version store invisible to an enclosing Git worktree", async () => {
6868
const root = await temporaryDirectory();
6969
const configPath = join(root, "agents.yaml");
70+
// Git hooks export repository-local variables; this fixture owns a different repository.
71+
const { stdout: localEnvironmentKeys } = await execFileAsync("git", ["rev-parse", "--local-env-vars"]);
72+
const env = { ...process.env };
73+
for (const key of localEnvironmentKeys.trim().split("\n")) delete env[key];
74+
const gitOptions = { cwd: root, env };
7075
await writeFile(configPath, projectYaml("Initial"));
71-
await execFileAsync("git", ["init", "--initial-branch", "main"], { cwd: root });
72-
await execFileAsync("git", ["add", "--", "agents.yaml"], { cwd: root });
73-
const before = await execFileAsync("git", ["status", "--porcelain=v1"], { cwd: root });
76+
await execFileAsync("git", ["init", "--initial-branch", "main"], gitOptions);
77+
await execFileAsync("git", ["add", "--", "agents.yaml"], gitOptions);
78+
const before = await execFileAsync("git", ["status", "--porcelain=v1"], gitOptions);
7479

7580
await enableProjectVersioning(configPath, "Baseline");
7681

77-
const after = await execFileAsync("git", ["status", "--porcelain=v1"], { cwd: root });
82+
const after = await execFileAsync("git", ["status", "--porcelain=v1"], gitOptions);
7883
expect(after.stdout).toBe(before.stdout);
7984
expect(after.stdout).not.toContain(".openagentpack");
8085
});

0 commit comments

Comments
 (0)