Skip to content

fix(parse): anchor .gitignore directory patterns correctly#3168

Open
nankingjing wants to merge 1 commit into
volcengine:mainfrom
nankingjing:fix/gitignore-dir-pattern-anchoring
Open

fix(parse): anchor .gitignore directory patterns correctly#3168
nankingjing wants to merge 1 commit into
volcengine:mainfrom
nankingjing:fix/gitignore-dir-pattern-anchoring

Conversation

@nankingjing

Copy link
Copy Markdown
Contributor

Summary

.gitignore directory 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).

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.
@nankingjing

Copy link
Copy Markdown
Contributor Author
Self-reviewed: diff is correct, minimal, and well-tested. No issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant