-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Exclude folder using exclamation mark ('!') doesn't work #6
Comments
@029xue Try switching the order of your patterns to:
If you have A second possibility is that the Windows paths are not matching properly. Can you try just using:
And let me know if that excludes the |
Hi, I tested and it shows no difference with !test1/ and, if just leave The result is empty, no any files is selected. |
The underlying issue is that Windows file paths are not being matched properly because Windows tends to use |
Thanks very much, waiting your updates :) |
@029xue I made some changes, and with my testing it should work now. Please note that the order of your patterns should be:
To first include all Also, list(spec.match_tree('d:\dev\eclipse_workspace\test_scan')) The changes are only reflected on Github right now. If my changes work for you, let me know and I'll update the version on PyPI. |
Thanks, works like charm now. So the patterns are working like filters from up to down? or just the excludes need be put in the last? |
Yes, the filters work from up to down. The order is what really matters. This is so that you can include (or exclude) a large amount of files, but then further down you really want to include (or exclude) a specific directory or smaller set of files. |
That make sense, thanks very much for the good library :) |
In 0.3.2, the fix to Issue cpburnz#6 in commit 45829da also changed the API of the spec object to return iterators instead of sets (see cpburnz#6 (comment)). This can break existing code using the library, so should be clearly mentioned
I'm using pattern
"""
!test1/
*.txt
"""
to scan a folder, from gitingore description
(http://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository)
ignore all files in the build/ directory
build/
this should exclude everything under test1 folder, but the run result shows the line dose not work, the result still show all contents under test 1 folder.
[An Example Folder Structure]
d:\dev\eclipse_workspace\test_scan\src\test1\a.txt
d:\dev\eclipse_workspace\test_scan\src\test1\b.txt
d:\dev\eclipse_workspace\test_scan\src\test1\c\c1.txt
d:\dev\eclipse_workspace\test_scan\src\test2\a.txt
d:\dev\eclipse_workspace\test_scan\src\test2\b.txt
d:\dev\eclipse_workspace\test_scan\src\test2\c\c1.txt
[Code]
SCAN_PATTERN = """
!test1/
*.txt
"""
spec = pathspec.PathSpec.from_lines(pathspec.GitIgnorePattern, SCAN_PATTERN.splitlines())
spec.match_tree('d:\dev\eclipse_workspace\test_scan')
[Run Result]
d:\dev\eclipse_workspace\test_scan\src\test1\a.txt
d:\dev\eclipse_workspace\test_scan\src\test1\b.txt
d:\dev\eclipse_workspace\test_scan\src\test1\c\c1.txt
d:\dev\eclipse_workspace\test_scan\src\test2\a.txt
d:\dev\eclipse_workspace\test_scan\src\test2\b.txt
d:\dev\eclipse_workspace\test_scan\src\test2\c\c1.txt
Can you please have a look? Thanks.
The text was updated successfully, but these errors were encountered: