Skip to content

Commit ad467e3

Browse files
authored
Merge pull request #63 from rjwignar/whitespacesTest
Allow directories with white-spaces to be passed
2 parents f6987b4 + 5b3cd8c commit ad467e3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

run-clang-format.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import subprocess
2323
import sys
2424
import traceback
25+
import re
2526
from distutils.util import strtobool
2627

2728
from functools import partial
@@ -241,14 +242,23 @@ def print_trouble(prog, message, use_colors):
241242
error_text = bold_red(error_text)
242243
print("{}: {} {}".format(prog, error_text, message), file=sys.stderr)
243244

245+
def normalize_paths(paths):
246+
"""
247+
Normalizes backward slashes in each path in list of paths
248+
Ex)
249+
"features/Test\ Features/feature.cpp" => "features/Test Features/feature.cpp"
250+
"""
251+
return [path.replace("\\","") for path in paths]
244252

245253
def split_list_arg(arg):
246254
"""
247255
If arg is a list containing a single argument it is split into multiple elements.
248256
Otherwise it is returned unchanged
249257
Workaround for GHA not allowing list arguments
250258
"""
251-
return arg[0].split() if len(arg) == 1 else arg
259+
# pattern matches all whitespaces except those preceded by a backslash, '\'
260+
pattern = r'(?<!\\)\s+'
261+
return normalize_paths(re.split(pattern, arg[0])) if len(arg) == 1 else arg
252262

253263

254264
def main():

0 commit comments

Comments
 (0)