forked from VimPlug/jedi
At present, .gitignore patterns not starting with '/' are classified as "ignored names" (opposing to "ignored paths") and not used for filtering directories. But, according to the spec [1], the situation is a bit different: all patterns apply to directories (and those ending with '/' apply to directories only). Besides that, there two kinds of patterns: those that match only w.r.t the directory where defining .gitignore is located (they must contain a '/' in the beginning or in the middle), which we call "absolute", and those that also match in all subdirectories under the directory where defining .gitignore is located (they must not contain '/' or contain only trailing '/'), which we call "relative". This commit implements handling of both "absolute" and "relative" .gitignore patterns according to the spec. "Absolute" patterns are handled mostly like `ignored_paths` were handled in the previous implementation. "Relative" patterns are collected into a distinct set containing `(defining_gitignore_dir, pattern)` tuples. For each traversed `root_folder_io`, all applicable "relative" patterns are expanded into a set of plain paths, which are then used for filtering `folder_io`s. While at it, also fix some minor issues. Explicitly ignore negative and wildcard patterns, since we don't handle them correctly anyway. Also, use '/' as a path separator instead of `os.path.sep` when dealing with .gitignore, since the spec explicitly says that '/' must be used on all platforms. [1] https://git-scm.com/docs/gitignore
11 KiB
11 KiB