Fix directory exclusion patterns to properly exclude contents#52
Merged
simone-viozzi merged 4 commits intomainfrom Nov 23, 2025
Merged
Fix directory exclusion patterns to properly exclude contents#52simone-viozzi merged 4 commits intomainfrom
simone-viozzi merged 4 commits intomainfrom
Conversation
- Fixed matches() method to properly handle directory patterns with trailing / - Directory patterns like "dir/" now correctly exclude the directory AND all its contents - Patterns with wildcards and trailing / (like "tmp/**/") now only match directories, not files - Improved may_have_late_include_descendant to avoid unnecessary traversal - Updated compressed view to only show directories without excluded children - All tests passing Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
- Updated README with comprehensive filtering documentation - Enhanced CLI help text with clear examples - Added 5 new tests specifically for user's issue scenarios - All 58 tests passing - Manual verification complete - all user scenarios work correctly Co-authored-by: simone-viozzi <19674168+simone-viozzi@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix inclusion/exclusion pattern issues in gpt-copy command
Fix directory exclusion patterns to properly exclude contents
Nov 19, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Directory exclusion patterns like
--exclude-dir appor-e "app/"were not excluding files within those directories. The patterns matched only the directory itself, not its contents.Changes
Core Pattern Matching
filter.py::matches(): Removed early return for files when pattern ends with/. Patterns likenode_modules/now match both the directory and all descendants. Wildcard patterns ending with/(e.g.,tmp/**/) now correctly match only directories.filter.py::_include_can_match_descendant(): Replaced naive**check with path prefix analysis. Prevents unnecessary traversal when patterns likebuild/reports/**cannot match undernode_modules/.Compressed View
gpt_copy.py::collect_file_info(): Added filter engine check when collecting children for compressed directory display. Previously only checked gitignore rules, now respects CLI patterns.Documentation
/behavior and last-match-wins semanticsExamples
Testing
Added 5 tests covering the reported scenarios. Updated 1 existing test to reflect correct behavior. All 58 tests pass.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.