fix(init): preserve inside=true on root lookup failures
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
---
|
||||
type: Fixed
|
||||
pr: 3491
|
||||
pr: 3502
|
||||
---
|
||||
**`/gsd-new-project` and `/gsd-ingest-docs` no longer create a nested `.git` inside an existing worktree (#3491)** — the shallow `has_git: false` check (which only looked for `.git` in the current directory) has been replaced with `git rev-parse --is-inside-work-tree` semantics. The init payload now surfaces `git_worktree_root` and `in_nested_subdir` so the workflows correctly skip `git init` when invoked from a subdirectory of an existing repo and warn that planning files will be tracked by the outer repo.
|
||||
|
||||
@@ -82,14 +82,18 @@ function gitWorktreeInfo(base: string): { inside: boolean; worktreeRoot: string
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
if (inside !== 'true') return { inside: false, worktreeRoot: null };
|
||||
const root = execSync('git rev-parse --show-toplevel', {
|
||||
cwd: base,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf-8',
|
||||
timeout: 5000,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
return { inside: true, worktreeRoot: root || null };
|
||||
try {
|
||||
const root = execSync('git rev-parse --show-toplevel', {
|
||||
cwd: base,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf-8',
|
||||
timeout: 5000,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
return { inside: true, worktreeRoot: root || null };
|
||||
} catch {
|
||||
return { inside: true, worktreeRoot: null };
|
||||
}
|
||||
} catch {
|
||||
return { inside: false, worktreeRoot: null };
|
||||
}
|
||||
|
||||
@@ -98,14 +98,18 @@ function gitWorktreeInfo(base: string): { inside: boolean; worktreeRoot: string
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
if (inside !== 'true') return { inside: false, worktreeRoot: null };
|
||||
const root = execSync('git rev-parse --show-toplevel', {
|
||||
cwd: base,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf-8',
|
||||
timeout: 5000,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
return { inside: true, worktreeRoot: root || null };
|
||||
try {
|
||||
const root = execSync('git rev-parse --show-toplevel', {
|
||||
cwd: base,
|
||||
stdio: ['ignore', 'pipe', 'ignore'],
|
||||
encoding: 'utf-8',
|
||||
timeout: 5000,
|
||||
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
||||
}).trim();
|
||||
return { inside: true, worktreeRoot: root || null };
|
||||
} catch {
|
||||
return { inside: true, worktreeRoot: null };
|
||||
}
|
||||
} catch {
|
||||
return { inside: false, worktreeRoot: null };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user