Test fix
diff --git a/pathspec/_backends/simple/gitignore.py b/pathspec/_backends/simple/gitignore.py index 29701f5..1157964 100644 --- a/pathspec/_backends/simple/gitignore.py +++ b/pathspec/_backends/simple/gitignore.py
@@ -85,6 +85,8 @@ priority = 2 if is_reversed: + if include and dir_mark: + return (include, index) if priority > out_priority: out_include = include out_index = index
diff --git a/tests/test_06_gitignore.py b/tests/test_06_gitignore.py index 04c5194..c295f9a 100644 --- a/tests/test_06_gitignore.py +++ b/tests/test_06_gitignore.py
@@ -731,3 +731,17 @@ includes = get_includes(results) debug = debug_results(spec, results) self.assertEqual(includes, set(), debug) + + def test_10_issue_134(self): + """ + Test a forward and reverse evaluation discrepancy. + """ + # WARNING: This will need to be modified when #129 is fixed. + for sub_test in self.parameterize_from_lines([ + "!**/node_modules/**", + "/node_modules", + ]): + with sub_test() as spec: + self.assertTrue(spec.match_file("node_modules")) # Agrees with git. + self.assertFalse(spec.match_file("node_modules/")) # BUG: Git says ignored. + self.assertFalse(spec.match_file("node_modules/leaf.txt")) # BUG: Git says ignored.