Skip to content

Commit 6bc1c1d

Browse files
committed
Address 74
1 parent 183f5e5 commit 6bc1c1d

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

CHANGES.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ Change History
33
==============
44

55

6+
0.11.1 (TBD)
7+
------------
8+
9+
Improvements:
10+
11+
- `Issue #74`_: Include directory should override exclude file.
12+
- `Pull #75`_: Fix partially unknown PathLike type.
13+
- Convert `os.PathLike` to a string properly using `os.fspath`.
14+
15+
.. _`Issue #74`: https://github.com/cpburnz/python-pathspec/issues/74
16+
.. _`Pull #75`: https://github.com/cpburnz/python-pathspec/pull/75
17+
18+
19+
620
0.11.0 (2023-01-24)
721
-------------------
822

pathspec/_meta.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"haimat <https://github.com/haimat>",
5050
"Avasam <https://github.com/Avasam>",
5151
"yschroeder <https://github.com/yschroeder>",
52+
"axesider <https://github.com/axesider>",
5253
]
5354
__license__ = "MPL 2.0"
5455
__version__ = "0.11.1.dev1"

pathspec/gitignore.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ def _match_file(
128128
# Pattern matched by a file pattern.
129129
priority = 2
130130

131-
if priority >= out_priority:
131+
if pattern.include and dir_mark:
132+
out_matched = pattern.include
133+
out_priority = priority
134+
elif priority >= out_priority:
132135
out_matched = pattern.include
133136
out_priority = priority
134137

tests/test_gitignore.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,3 +358,33 @@ def test_06_issue_64(self):
358358
}
359359
ignores = set(spec.match_files(files))
360360
self.assertEqual(ignores, files)
361+
362+
def test_07_issue_74(self):
363+
"""
364+
Test include directory should override exclude file.
365+
"""
366+
spec = GitIgnoreSpec.from_lines([
367+
'*', # Ignore all files by default
368+
'!*/', # but scan all directories
369+
'!*.txt', # Text files
370+
'/test1/**', # ignore all in the directory
371+
])
372+
files = {
373+
'test1/b.bin',
374+
'test1/a.txt',
375+
'test1/c/c.txt',
376+
'test2/a.txt',
377+
'test2/b.bin',
378+
'test2/c/c.txt',
379+
}
380+
ignores = set(spec.match_files(files))
381+
self.assertEqual(ignores, {
382+
'test1/b.bin',
383+
'test1/a.txt',
384+
'test1/c/c.txt',
385+
'test2/b.bin',
386+
})
387+
self.assertEqual(files - ignores, {
388+
'test2/a.txt',
389+
'test2/c/c.txt',
390+
})

0 commit comments

Comments
 (0)