fix: respect .planning/ in linked worktrees before resolving to main repo
resolveWorktreeRoot() unconditionally resolved linked worktrees to the main repo root. When a linked worktree has its own independent .planning/ directory (e.g., Conductor workspaces), all GSD commands read/wrote the wrong planning state. Add an early return that checks for a local .planning/ before falling through to main repo resolution. The caller in gsd-tools.cjs already had this guard (added in #1283), but the function itself should be correct regardless of call site. This is defense-in- depth for any future callers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -451,6 +451,12 @@ function execGit(cwd, args) {
|
||||
* Returns the main worktree path, or cwd if not in a worktree.
|
||||
*/
|
||||
function resolveWorktreeRoot(cwd) {
|
||||
// If the current directory already has its own .planning/, respect it.
|
||||
// This handles linked worktrees with independent planning state (e.g., Conductor workspaces).
|
||||
if (fs.existsSync(path.join(cwd, '.planning'))) {
|
||||
return cwd;
|
||||
}
|
||||
|
||||
// Check if we're in a linked worktree
|
||||
const gitDir = execGit(cwd, ['rev-parse', '--git-dir']);
|
||||
const commonDir = execGit(cwd, ['rev-parse', '--git-common-dir']);
|
||||
|
||||
Reference in New Issue
Block a user