Skip to content

Include directory should override exclude file #74

@axesider

Description

@axesider
import pathspec spec = pathspec.GitIgnoreSpec.from_lines([ '*', # Ignore all files by default '!*/', # but scan all directories '!*.txt', # Text files '/test1/**' # ignore all in the directory ]) files = { 'test1/b.bin', 'test1/a.txt', 'test1/c/c.txt', 'test2/a.txt', 'test2/b.bin', 'test2/c/c.txt', } ignores = set(spec.match_files(files)) print(ignores) 

{'test1/b.bin', 'test2/b.bin'}

It should be

{'test1/a.txt', 'test1/c/c.txt', 'test1/b.bin', 'test2/b.bin'}

I think GitIgnoreSpec._match_file should have something like:

 if pattern.include is False and dir_mark and out_priority == 0: out_matched = pattern.include out_priority = priority elif pattern.include is True and dir_mark: out_matched = pattern.include out_priority = priority elif priority >= out_priority: out_matched = pattern.include out_priority = priority 

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