Skip to content

Since version 0.10.0 pure wildcard does not work in some cases #62

@bzakdd

Description

@bzakdd

Behavior of pattern "match everything" changed when upgrading from version 0.9.0 to 0.10.0:


Version 0.9.0

>>> import pathspec
>>> patterns = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ["*"])
>>> 
>>> print(patterns.match_file('anydir/file.txt'))
True

Result is as expected


Version 0.10.0

>>> import pathspec
>>> patterns = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ["*"])
>>> 
>>> print(patterns.match_file('anydir/file.txt'))
False

Result is wrong. * should match any file, but it doesn't match anydir/file.txt.


Discovered when checking case "match everything except for one directory":

patterns = pathspec.PathSpec.from_lines(pathspec.patterns.GitWildMatchPattern, ["*", "!product_dir/"])

On version 0.9.0 it correctly matches file outside of product_dir and doesn't match file inside:

>>> print(patterns.match_file('anydir/file.txt'))
True
>>> print(patterns.match_file('product_dir/file.txt'))
False

On version 0.10.0 it doesn't match in either case:

>>> print(patterns.match_file('anydir/file.txt'))
False
>>> print(patterns.match_file('product_dir/file.txt'))
False

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions