-
Notifications
You must be signed in to change notification settings - Fork 49
Closed
Description
Some patterns work with both absolute and relative paths.
For example,
>>> list(pathspec.patterns.GitWildMatchPattern("*.py").match(["/foo/a.py", "foo/a.py", "x/foo/a.py", "/x/foo/a.py"]))
['/foo/a.py', 'foo/a.py', 'x/foo/a.py', '/x/foo/a.py']
>>> list(pathspec.patterns.GitWildMatchPattern("**").match(["/foo/a.py", "foo/a.py", "x/foo/a.py", "/x/foo/a.py"]))
['/foo/a.py', 'foo/a.py', 'x/foo/a.py', '/x/foo/a.py']
However, the pattern foo or /foo won't match the path starts with /foo.
For example,
>>> list(pathspec.patterns.GitWildMatchPattern("foo").match(["/foo/a.py", "foo/a.py", "x/foo/a.py", "/x/foo/a.py"]))
['foo/a.py', 'x/foo/a.py', '/x/foo/a.py']
>>> list(pathspec.patterns.GitWildMatchPattern("/foo").match(["/foo/a.py", "foo/a.py", "x/foo/a.py", "/x/foo/a.py"]))
['foo/a.py']
Can we support matching the absolute path in this case?
I think making output.append('(?:.+/)?') at here output.append('(?:.*/)?') could solve the issue, but I am not sure whether it has other unwanted side effect.
Another solution is that we normalize /... to ... similar to normalizing the ./ at here.
Metadata
Metadata
Assignees
Labels
No labels