-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: respect .gitignore patterns for directories in list_files tool (#5393) #5394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…5393) - Replace custom gitignore parsing with proper 'ignore' library - Fix directory filtering to respect .gitignore patterns in both recursive and non-recursive modes - Add support for parent .gitignore files - Remove --no-ignore-vcs flag from non-recursive mode for consistent behavior - Add comprehensive tests for gitignore functionality Fixes #5393
|
✅ No security or compliance issues detected. Reviewed everything up to f1250a4. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
daniel-lxs
approved these changes
Jul 9, 2025
mrubens
reviewed
Jul 9, 2025
Co-authored-by: Matt Rubens <[email protected]>
6 tasks
mrubens
reviewed
Jul 9, 2025
mrubens
approved these changes
Jul 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
Something isn't working
lgtm
This PR has been approved by a maintainer
PR - Needs Review
size:L
This PR changes 100-499 lines, ignoring generated files.
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
Fixes #5393
This PR resolves an issue where the
list_filestool incorrectly returned directories that should be ignored according to.gitignorepatterns. The problem was caused by inconsistent gitignore handling between file and directory listing logic.Root Cause
The
list_filestool had three main issues:.gitignorein recursive mode.gitignorepatterns.gitignoreentirely - used--no-ignore-vcsflagChanges Made
🔧 Replaced custom gitignore parsing with proper
ignorelibraryparseGitignoreFileandisIgnoredByGitignorefunctionscreateIgnoreInstanceusing the sameignorelibrary used elsewhere in the codebase📁 Fixed parent
.gitignorefile handlingfindGitignoreFilesfunction that walks up the directory tree.gitignorefiles from parent directories, not just the target directory🔄 Made non-recursive mode respect
.gitignore--no-ignore-vcsflag from non-recursive ripgrep calls.gitignore🎯 Improved directory filtering logic
shouldIncludeDirectoryto use theignorelibrary for proper pattern matchingTesting
.gitignore.gitignorefile handlingVerification of Acceptance Criteria
.gitignorepatterns are now properly excluded fromlist_filesoutput.gitignorepatterns.gitignorefiles are properly considered when filtering directoriesFiles Changed
src/services/glob/list-files.ts- Main implementation fixsrc/services/glob/__tests__/gitignore-test.spec.ts- Added comprehensive testssrc/services/glob/__tests__/gitignore-integration.spec.ts- Added integration testsChecklist
Impact
This fix ensures that the
list_filestool now consistently respects.gitignorepatterns for both files and directories in both recursive and non-recursive modes, resolving the reported issue and improving the overall reliability of directory listing functionality.Important
Fixes
list_filestool to respect.gitignorepatterns for directories using theignorelibrary.list_filestool now respects.gitignorepatterns for directories in both recursive and non-recursive modes.--no-ignore-vcsflag from non-recursive ripgrep calls.ignorelibrary inlist-files.ts.createIgnoreInstanceandfindGitignoreFilesfunctions for handling.gitignorefiles.shouldIncludeDirectoryto useignorelibrary for pattern matching.gitignore-test.spec.tsandgitignore-integration.spec.tsfor comprehensive testing of.gitignorehandling..gitignorefiles and complex patterns.This description was created by
for 3b11b58. You can customize this summary. It will automatically update as commits are pushed.