From ba8f07d8366cddad29edd80ddab3e19ceff1edcf Mon Sep 17 00:00:00 2001 From: Jaen Date: Thu, 24 Jul 2025 23:35:54 +0300 Subject: [PATCH] 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 --- src/serena/util/file_system.py | 3 --- test/serena/util/test_file_system.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/serena/util/file_system.py b/src/serena/util/file_system.py index cf1bacc..4c667b0 100644 --- a/src/serena/util/file_system.py +++ b/src/serena/util/file_system.py @@ -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: diff --git a/test/serena/util/test_file_system.py b/test/serena/util/test_file_system.py index 3c9fd14..97b9e3f 100644 --- a/test/serena/util/test_file_system.py +++ b/test/serena/util/test_file_system.py @@ -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."""