fix(init): preserve inside=true on root lookup failures

This commit is contained in:
Tom Boucher
2026-05-14 09:56:36 -04:00
parent fb6633ceda
commit 5a8495adb7
3 changed files with 25 additions and 17 deletions

View File

@@ -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 };
}