When the user's home directory is a git repo, resolveProjectRoot() correctly returns $HOME as the main tree root. assertSafeDirectory() then hard-blocks it with the home-directory guard added in #1053, even though the session is running from a valid GSD worktree (e.g. ~/.gsd/worktrees/M001) — not from $HOME itself. Fix: in projectRoot(), detect when CWD diverges from the resolved root (i.e. we are inside a git worktree) and validate the CWD instead. The worktree path is never $HOME, so the guard no longer fires. When not in a worktree cwd === root, preserving the existing behaviour unchanged. Adds a regression test: validateDirectory() on a ~/.gsd/worktrees/M001 path must return { safe: true, severity: "ok" }. Co-authored-by: Jeremy McSpadden <jeremy@fluxlabs.net>
This commit is contained in:
parent
5eed57f876
commit
bdeec039c0
1 changed files with 15 additions and 0 deletions
|
|
@ -101,6 +101,21 @@ test("validateDirectory: subdirectory of home is NOT blocked", () => {
|
|||
}
|
||||
});
|
||||
|
||||
// Regression test for #1317: GSD worktree inside $HOME must not be blocked even
|
||||
// when the resolved project root equals $HOME (e.g. home dir is a git repo).
|
||||
test("validateDirectory: GSD worktree path nested under home is NOT blocked (#1317)", () => {
|
||||
const worktreePath = join(homedir(), ".gsd", "worktrees", "M001");
|
||||
mkdirSync(worktreePath, { recursive: true });
|
||||
try {
|
||||
// The worktree CWD itself is a valid location — it must pass.
|
||||
const result = validateDirectory(worktreePath);
|
||||
assert.equal(result.safe, true, "GSD worktree path should be safe to run in");
|
||||
assert.equal(result.severity, "ok");
|
||||
} finally {
|
||||
rmSync(join(homedir(), ".gsd", "worktrees", "M001"), { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
// ─── Temp directory root ─────────────────────────────────────────────────────────
|
||||
|
||||
test("validateDirectory: temp directory root is blocked", () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue