fix(gsd): skip same-path planning artifact copies
This commit is contained in:
parent
f18d8e9f30
commit
ccd6618f19
2 changed files with 22 additions and 1 deletions
|
|
@ -1137,6 +1137,7 @@ function copyPlanningArtifacts(srcBase: string, wtPath: string): void {
|
|||
const srcGsd = join(srcBase, ".gsd");
|
||||
const dstGsd = join(wtPath, ".gsd");
|
||||
if (!existsSync(srcGsd)) return;
|
||||
if (isSamePath(srcGsd, dstGsd)) return;
|
||||
|
||||
// Copy milestones/ directory (planning files, roadmaps, plans, research)
|
||||
safeCopyRecursive(join(srcGsd, "milestones"), join(dstGsd, "milestones"), {
|
||||
|
|
@ -2020,4 +2021,3 @@ export function mergeMilestoneToMain(
|
|||
|
||||
return { commitMessage, pushed, prCreated, codeFilesChanged };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
test("copyPlanningArtifacts skips when source and destination .gsd resolve to the same path", () => {
|
||||
const srcPath = join(import.meta.dirname, "..", "auto-worktree.ts");
|
||||
const src = readFileSync(srcPath, "utf-8");
|
||||
|
||||
const fnIdx = src.indexOf("function copyPlanningArtifacts");
|
||||
assert.ok(fnIdx !== -1, "copyPlanningArtifacts function exists");
|
||||
|
||||
const fnBody = src.slice(fnIdx, fnIdx + 2400);
|
||||
|
||||
const guardIdx = fnBody.indexOf("if (isSamePath(srcGsd, dstGsd)) return;");
|
||||
const copyIdx = fnBody.indexOf("safeCopyRecursive(join(srcGsd, \"milestones\")");
|
||||
|
||||
assert.ok(guardIdx !== -1, "copyPlanningArtifacts should guard same-path .gsd copies");
|
||||
assert.ok(copyIdx !== -1, "copyPlanningArtifacts should still copy milestones when paths differ");
|
||||
assert.ok(guardIdx < copyIdx, "same-path guard should run before any copy attempt");
|
||||
});
|
||||
Loading…
Add table
Reference in a new issue