Repository navigation
Fixes for handling .gitignore edge cases in GitIgnorePattern. - #8
Merged
Merged
Conversation
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. More complex behavior, such as an include pattern followed by an exclude pattern were not tested since they would involve integration tests.
Owner
|
Thank you for finding out these edge cases and taking the time to fix them. I guess git's pattern matching is more complicated than I realized. |
cpburnz
added a commit
that referenced
this pull request
May 16, 2015
Fixes for handling .gitignore edge cases in GitIgnorePattern.
Contributor
Author
|
Thank you! |
jdpace
added a commit
to jdpace/pathspec-ruby
that referenced
this pull request
May 24, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/pathmatches:abs/path/foospammatches:spam/,spam/foospam/twodoes NOT match:foo/spam/twospam/**does NOT match:foo/spam/barleft/**/rightdoes NOT match:foo/left/bar/right**/spamdoes match:foo/spam/,foo/spam/barfoo-*-bardoes match:foo-hello-bar/baz~temp-*does match:~temp-foo/bar*.pydoes match:bar.py/bazTests 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 CASEcomments 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!