Skip to content

Commit 797fe4d

Browse files
committed
extended split_list_arg to split by whitespaces while ignoring filepaths with whitespaces (escaped with '\'
extended list_files to normalize filepaths containing whitespaces (escaped with '\')
1 parent f85c199 commit 797fe4d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

run-clang-format.py

+10
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
@@ -69,6 +70,7 @@ def list_files(files, recursive=False, extensions=None, exclude=None):
6970

7071
out = []
7172
for file in files:
73+
file = file.replace("\\", "")
7274
if recursive and os.path.isdir(file):
7375
for dirpath, dnames, fnames in os.walk(file):
7476
fpaths = [os.path.join(dirpath, fname) for fname in fnames]
@@ -248,6 +250,14 @@ def split_list_arg(arg):
248250
Otherwise it is returned unchanged
249251
Workaround for GHA not allowing list arguments
250252
"""
253+
pattern = r'(?<!\\)\s+'
254+
if len(arg) == 1:
255+
# split list by regex
256+
paths = re.split(pattern, arg[0])
257+
for path in paths:
258+
# normalize paths by removing forward slashes
259+
path = path.replace("\\", "")
260+
return paths
251261
return arg[0].split() if len(arg) == 1 else arg
252262

253263

0 commit comments

Comments
 (0)