Is your feature request related to a problem? Please describe.
Hi, I'm the author of pathspec, and recently released v1. The biggest change is GitWildMatchPattern (a.k.a. "gitwildmatch") was split into two different implementations. (1) GitIgnoreBasicPattern (a.k.a. "gitignore") is new and properly implements the patterns in gitignore's documentation. (2) GitIgnoreSpecPattern is the previous GitWildMatchPattern implementation and is used by GitIgnoreSpec to implement Git's edge-cases.
PathSpec
The form PathSpec.from_lines('gitwildmatch', ...) is now deprecated because it does not fully match the behavior of the gitignore docs or Git itself. There's 3 possible replacements depending on the exact behavior you want:
-
To keep the exact behavior as before, use PathSpec.from_lines(GitIgnoreSpecPattern, ...). This is the non-deprecated equivalent to using "gitwildmatch". I discourage this use because it's a hybrid between Git's behavior and the gitignore docs.
from pathspec.patterns.gitignore.spec import GitIgnoreSpecPattern
-
To follow the gitignore docs, use PathSpec.from_lines('gitignore', ...). The change for using this form is "foo/*" will no longer match files in subdirectories, and the exact pattern "/" is equivalent to "**" (match everything) rather than being a no-op.
-
To follow Git's implementation, use GitIgnoreSpec.from_lines(...). The change for using this is Git allows including files from excluded directories which directly contradicts the gitignore docs.
|
return PathSpec.from_lines("gitwildmatch", lines) |
|
gitignore = PathSpec.from_lines( |
|
"gitwildmatch", ["exclude/", ".definitely_exclude"] |
|
) |
|
gitignore = PathSpec.from_lines("gitwildmatch", []) |
GitIgnorePatternError
pathspec.patterns.gitwildmatch.GitWildMatchPatternError is now a deprecated alias of pathspec.patterns.gitignore.GitIgnorePatternError. I recommend switching to GitIgnorePatternError.
|
from pathspec.patterns.gitwildmatch import GitWildMatchPatternError |
|
from pathspec.patterns.gitwildmatch import GitWildMatchPatternError |
Is your feature request related to a problem? Please describe.
Hi, I'm the author of pathspec, and recently released v1. The biggest change is GitWildMatchPattern (a.k.a. "gitwildmatch") was split into two different implementations. (1) GitIgnoreBasicPattern (a.k.a. "gitignore") is new and properly implements the patterns in gitignore's documentation. (2) GitIgnoreSpecPattern is the previous GitWildMatchPattern implementation and is used by GitIgnoreSpec to implement Git's edge-cases.
PathSpec
The form
PathSpec.from_lines('gitwildmatch', ...)is now deprecated because it does not fully match the behavior of the gitignore docs or Git itself. There's 3 possible replacements depending on the exact behavior you want:To keep the exact behavior as before, use
PathSpec.from_lines(GitIgnoreSpecPattern, ...). This is the non-deprecated equivalent to using "gitwildmatch". I discourage this use because it's a hybrid between Git's behavior and the gitignore docs.To follow the gitignore docs, use
PathSpec.from_lines('gitignore', ...). The change for using this form is "foo/*" will no longer match files in subdirectories, and the exact pattern "/" is equivalent to "**" (match everything) rather than being a no-op.To follow Git's implementation, use
GitIgnoreSpec.from_lines(...). The change for using this is Git allows including files from excluded directories which directly contradicts the gitignore docs.black/src/black/files.py
Line 249 in c3cc5a9
black/tests/test_black.py
Lines 2517 to 2519 in c3cc5a9
black/tests/test_black.py
Line 2693 in c3cc5a9
GitIgnorePatternError
pathspec.patterns.gitwildmatch.GitWildMatchPatternError is now a deprecated alias of pathspec.patterns.gitignore.GitIgnorePatternError. I recommend switching to GitIgnorePatternError.
black/src/black/files.py
Line 14 in c3cc5a9
black/src/black/__init__.py
Line 27 in c3cc5a9