X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/b1d060101626aa1c332f52e4bdf0ae5e4cc07990..1e0ec543ff3a7de715c8ee3359c8defb2c2c0e0d:/src/black/files.py?ds=sidebyside diff --git a/src/black/files.py b/src/black/files.py index ba60c84..4d7b47a 100644 --- a/src/black/files.py +++ b/src/black/files.py @@ -18,6 +18,7 @@ from typing import ( ) from pathspec import PathSpec +from pathspec.patterns.gitwildmatch import GitWildMatchPatternError import tomli from black.output import err @@ -122,7 +123,11 @@ def get_gitignore(root: Path) -> PathSpec: if gitignore.is_file(): with gitignore.open(encoding="utf-8") as gf: lines = gf.readlines() - return PathSpec.from_lines("gitwildmatch", lines) + try: + return PathSpec.from_lines("gitwildmatch", lines) + except GitWildMatchPatternError as e: + err(f"Could not parse {gitignore}: {e}") + raise def normalize_path_maybe_ignore(