Fix gitignore anchored pattern logic and update test

- Use correct anchoring logic: only patterns starting with '/' are anchored
- Fix test expectation for negation patterns to match Git behavior
- Apply code formatting
This commit is contained in:
Jaen
2025-07-24 23:35:54 +03:00
parent 1d65c85485
commit ba8f07d836
2 changed files with 1 additions and 4 deletions
-3
View File
@@ -205,9 +205,6 @@ class GitignoreParser:
if is_anchored:
line = line[1:]
# Remove directory marker at the end since we do not support directory-only patterns
line = line.removesuffix("/")
# Adjust pattern based on gitignore file location
if rel_dir:
if is_anchored:
+1 -1
View File
@@ -369,7 +369,7 @@ debug.log
assert "*.log" in patterns
assert "!important.log" in patterns
assert "!/src/keep.log" in patterns
assert "!src/keep.log" in patterns
def test_comments_and_empty_lines(self):
"""Test that comments and empty lines are ignored."""