From 5ce90f7b6e1316146abd731b9f03a437dbf9769e Mon Sep 17 00:00:00 2001 From: Dominic Kempf Date: Wed, 20 Mar 2024 14:25:01 +0100 Subject: [PATCH] Filter out files that do not exist in the working copy --- precommend/core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/precommend/core.py b/precommend/core.py index 951e48e..887edf4 100644 --- a/precommend/core.py +++ b/precommend/core.py @@ -10,7 +10,9 @@ class GenerationContext: def __init__(self): self._path = os.path.realpath(".") - self._files = get_all_files() + # We use get_all_files from pre-commit as it respects .gitignore, but + # we need to filter out files that do not exist in the working copy. + self._files = [f for f in get_all_files() if os.path.exists(f)] self._tags = functools.reduce( lambda a, b: a.union(b), map(tags_from_path, self._files), set() )