fix(parse): anchor .gitignore directory patterns correctly#3168
Open
nankingjing wants to merge 1 commit into
Open
fix(parse): anchor .gitignore directory patterns correctly#3168nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
A trailing slash (e.g. build/) counted as an internal '/', so _transform_gitignore_line anchored the pattern to base_rel instead of matching it at any depth. Strip the trailing slash before the anchoring decision and re-append it afterward so directory-only markers keep their unanchored semantics.
Contributor
Author
| Self-reviewed: diff is correct, minimal, and well-tested. No issues found. |
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.
Summary
.gitignoredirectory patterns (trailing/) were anchored incorrectly, so directory-only patterns could match the wrong paths (or fail to match nested directories) during ignore parsing.Problem
The parser conflated the trailing-slash (directory-only) marker with the anchoring decision, so
foo/and anchoring were resolved together and produced incorrect matches.Fix
Strip and record the trailing
/(directory-only) marker before making the anchoring decision, so directory patterns anchor consistently with gitignore semantics.Test
tests/parse/test_gitignore_dir_anchoring.py— covers directory-only patterns, anchored vs unanchored, and nested matches (5 passed).