fix: explicitly exclude .git directories from codebase indexing for improved performance #9050
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses Issue #9048 regarding slow codebase indexing by explicitly excluding .git directories from file listing operations.
Problem
Users reported slow codebase indexing, specifically mentioning that large .git folders were being processed. While .git was already in the DIRS_TO_IGNORE list, there were scenarios where it could still be included:
Solution
Changes
src/services/glob/list-files.ts
-g '!**/.git/**'pattern in recursive mode-g '!.git'and-g '!.git/**'patterns in non-recursive modesrc/services/glob/tests/list-files-git-exclusion.spec.ts
Impact
Testing
Notes
While .git was already in DIRS_TO_IGNORE, this explicit exclusion provides an extra layer of protection and ensures consistent behavior across all code paths. The user also mentioned wanting to exclude "these folders and files" (plural), suggesting they may want a more general exclusion mechanism. If needed, we can explore adding a configuration option for custom exclusions in a follow-up PR.
Fixes #9048
Important
Explicitly excludes
.gitdirectories from indexing inlist-files.tsto improve performance, with comprehensive tests inlist-files-git-exclusion.spec.ts..gitdirectories from indexing inlist-files.tsfor both recursive and non-recursive modes..gitexclusion even when--no-ignore-vcsand--no-ignoreflags are used.-g '!**/.git/**'in recursive mode and-g '!.git',-g '!.git/**'in non-recursive mode inlist-files.ts.list-files-git-exclusion.spec.tsto test.gitexclusion in various scenarios, including recursive, non-recursive, and when targeting hidden directories.This description was created by
for a59ca7b. You can customize this summary. It will automatically update as commits are pushed.