X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/ef7c45f28132a7704a4549072ce5b272034fa196..104aec555fae0883ef5b53709569bd9c4d420bc5:/src/black/files.py 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(