fix(extraction): diagnose git→FS scan fallback and lock nested .gitignore (#1567) (#1750)

Could not reproduce the reported nested-gitignore node_modules blowup on
Linux against main (or with the real Boba-Base ignore files): both the git
ls-files path and scanDirectoryWalk already exclude via DEFAULT_IGNORE and
per-directory .gitignore. Add CODEGRAPH_DEBUG logging when the git listing
falls back, plus regression tests for the reporter's layout on both scan
paths so a future regression fails loudly.

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
Colby Mchenry
2026-09-08 00:53:09 -05:00
committed by GitHub
co-authored by Colby McHenry
parent a6f52d737a
commit bb204f8855
2 changed files with 117 additions and 1 deletions
+18 -1
View File
@@ -1050,6 +1050,10 @@ function getGitVisibleFiles(rootDir: string): Set<string> | null {
{ cwd: rootDir, encoding: 'utf-8', timeout: 5000, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }
);
// Directory is gitignored by parent repo — fall back to filesystem walk
logDebug('project root is gitignored by a parent repo — falling back to filesystem walk', {
rootDir,
gitRoot,
});
return null;
} catch {
// Not ignored — safe to use git ls-files
@@ -1074,7 +1078,20 @@ function getGitVisibleFiles(rootDir: string): Set<string> | null {
// Git, but still wanted in the graph.)
for (const f of collectIncludedFilesForRoot(rootDir)) visible.add(f);
return visible;
} catch {
} catch (error) {
// Any failure here (git missing, a `git rev-parse`/`ls-files` timeout or
// buffer overrun under load, an unreadable repo, unsupported flag combo on
// older git, etc.) silently sent every caller to `scanDirectoryWalk` with
// zero signal that the fast git-delegated path was skipped — making reports
// like #1567 (nested-`.gitignore`-excluded `node_modules` walked into)
// hard to triage, since both ignore implementations look correct in
// isolation but there was no way to tell which one ran. Log it under the
// existing CODEGRAPH_DEBUG gate so a future report can confirm or rule out
// the fallback in one step.
logDebug('git-based file listing unavailable — falling back to filesystem walk', {
rootDir,
error: error instanceof Error ? error.message : String(error),
});
return null;
}
}