fix(browse): add timeout to git check-ignore and clarify false return

Addresses review feedback from kraftbj:
- Add timeout: 2_000 to Bun.spawnSync to prevent indefinite hangs on
  network filesystems or slow credential helpers
- Add comment explaining why the catch returns false (intentionally
  collapses "not ignored" and "git errored" since falling through to
  the text-check is the safe default)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Greg Jackson 2026-08-06 14:26:02 +01:00
parent 670af8bfbc
commit d7540ee2d5
1 changed files with 3 additions and 0 deletions

View File

@ -82,9 +82,12 @@ function isIgnoredByGit(projectDir: string, relPath: string): boolean {
try {
const proc = Bun.spawnSync(['git', 'check-ignore', '-q', '--', relPath], {
cwd: projectDir, stdout: 'pipe', stderr: 'pipe',
timeout: 2_000,
});
return proc.exitCode === 0;
} catch {
// git not found, timed out, or not a repo (exit 128). Fall through to
// the text-check path — appending is the safe default when unsure.
return false;
}
}