From 8ddeaab59d9bbe699eeedb9105b8355296e28a9f Mon Sep 17 00:00:00 2001 From: Nicolas Phister Date: Wed, 3 Nov 2021 14:43:37 +0100 Subject: [PATCH] surround filenames containing whitespace with quotes --- pre_commit/commands/run.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 2714faf4..d8b5aeae 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -109,6 +109,12 @@ class Classifier: hook.types_or, hook.exclude_types, ) + + # surround filenames containing whitespace with quotes + for f in names: + if re.search(r"\s", f): + f = '"' + f + '"' + return tuple(names) @classmethod