Skip to content

Commit

Permalink
Address 74
Browse files Browse the repository at this point in the history
  • Loading branch information
cpburnz committed Feb 26, 2023
1 parent 183f5e5 commit 6bc1c1d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ Change History
==============


0.11.1 (TBD)
------------

Improvements:

- `Issue #74`_: Include directory should override exclude file.
- `Pull #75`_: Fix partially unknown PathLike type.
- Convert `os.PathLike` to a string properly using `os.fspath`.

.. _`Issue #74`: https://github.com/cpburnz/python-pathspec/issues/74
.. _`Pull #75`: https://github.com/cpburnz/python-pathspec/pull/75



0.11.0 (2023-01-24)
-------------------

Expand Down
1 change: 1 addition & 0 deletions pathspec/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"haimat <https://github.com/haimat>",
"Avasam <https://github.com/Avasam>",
"yschroeder <https://github.com/yschroeder>",
"axesider <https://github.com/axesider>",
]
__license__ = "MPL 2.0"
__version__ = "0.11.1.dev1"
5 changes: 4 additions & 1 deletion pathspec/gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,10 @@ def _match_file(
# Pattern matched by a file pattern.
priority = 2

if priority >= out_priority:
if pattern.include and dir_mark:
out_matched = pattern.include
out_priority = priority
elif priority >= out_priority:
out_matched = pattern.include
out_priority = priority

Expand Down
30 changes: 30 additions & 0 deletions tests/test_gitignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,33 @@ def test_06_issue_64(self):
}
ignores = set(spec.match_files(files))
self.assertEqual(ignores, files)

def test_07_issue_74(self):
"""
Test include directory should override exclude file.
"""
spec = GitIgnoreSpec.from_lines([
'*', # Ignore all files by default
'!*/', # but scan all directories
'!*.txt', # Text files
'/test1/**', # ignore all in the directory
])
files = {
'test1/b.bin',
'test1/a.txt',
'test1/c/c.txt',
'test2/a.txt',
'test2/b.bin',
'test2/c/c.txt',
}
ignores = set(spec.match_files(files))
self.assertEqual(ignores, {
'test1/b.bin',
'test1/a.txt',
'test1/c/c.txt',
'test2/b.bin',
})
self.assertEqual(files - ignores, {
'test2/a.txt',
'test2/c/c.txt',
})

0 comments on commit 6bc1c1d

Please sign in to comment.