Skip to content

Commit

Permalink
Merge pull request #63 from rjwignar/whitespacesTest
Browse files Browse the repository at this point in the history
Allow directories with white-spaces to be passed
  • Loading branch information
DoozyX authored Dec 21, 2023
2 parents f6987b4 + 5b3cd8c commit ad467e3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 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 @@ -241,14 +242,23 @@ def print_trouble(prog, message, use_colors):
error_text = bold_red(error_text)
print("{}: {} {}".format(prog, error_text, message), file=sys.stderr)

def normalize_paths(paths):
"""
Normalizes backward slashes in each path in list of paths
Ex)
"features/Test\ Features/feature.cpp" => "features/Test Features/feature.cpp"
"""
return [path.replace("\\","") for path in paths]

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


def main():
Expand Down

0 comments on commit ad467e3

Please sign in to comment.