Fixes for handling .gitignore edge cases in GitIgnorePattern. #8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The git client (tested with v2.4.1) exhibits differing behavior than pathspec's GitIgnorePattern, including:
/
does NOT match all paths the repo/abs/path
matches:abs/path/foo
spam
matches:spam/
,spam/foo
spam/two
does NOT match:foo/spam/two
spam/**
does NOT match:foo/spam/bar
left/**/right
does NOT match:foo/left/bar/right
**/spam
does match:foo/spam/
,foo/spam/bar
foo-*-bar
does match:foo-hello-bar/baz
~temp-*
does match:~temp-foo/bar
*.py
does match:bar.py/baz
Tests for each of these cases have been added. While some of these edge cases may be bugs in git, until they are fixed, I believe that pathspec should handle .gitignore files as close as possible to how git handles them. I marked these edge cases with
EDGE CASE
comments so that they can be easily removed in the future.More complex behavior, such as an include pattern followed by an exclude pattern were not tested since they would involve integration tests.
Thank you so much for creating this library!