Skip to content

Commit

Permalink
extended split_list_arg to split by whitespaces while ignoring filepa…
Browse files Browse the repository at this point in the history
…ths with whitespaces (escaped with '\'

extended list_files to normalize filepaths containing whitespaces (escaped with '\')
  • Loading branch information
rjwignar committed Dec 6, 2023
1 parent f85c199 commit 797fe4d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions run-clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import subprocess
import sys
import traceback
import re
from distutils.util import strtobool

from functools import partial
Expand Down Expand Up @@ -69,6 +70,7 @@ def list_files(files, recursive=False, extensions=None, exclude=None):

out = []
for file in files:
file = file.replace("\\", "")
if recursive and os.path.isdir(file):
for dirpath, dnames, fnames in os.walk(file):
fpaths = [os.path.join(dirpath, fname) for fname in fnames]
Expand Down Expand Up @@ -248,6 +250,14 @@ def split_list_arg(arg):
Otherwise it is returned unchanged
Workaround for GHA not allowing list arguments
"""
pattern = r'(?<!\\)\s+'
if len(arg) == 1:
# split list by regex
paths = re.split(pattern, arg[0])
for path in paths:
# normalize paths by removing forward slashes
path = path.replace("\\", "")
return paths
return arg[0].split() if len(arg) == 1 else arg


Expand Down

0 comments on commit 797fe4d

Please sign in to comment.