Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow directories with white-spaces to be passed #63

Merged
merged 6 commits into from
Dec 21, 2023

Conversation

rjwignar
Copy link
Contributor

@rjwignar rjwignar commented Dec 7, 2023

This fixes #62

Summary of Changes

run-clang-format.py:

  • added normalize_paths() to normalize backslashes in all elements of a list of file paths.
    • I originally considered using os.path.normpath but wasn't able to use it to normalize the backslashes
  • extended split_list_arg(arg) to split arg by regex pattern (all white spaces except those preceded by a backslash) and then normalize any backslashes using normalize_paths()

Testing

The modified run-clang-format.py file was tested on Ubuntu 18.04.6 LTS using the following command:

python3 ../../clang-format-lint-action/run-clang-format.py --clang-format-executable /usr/bin/clang-format-16 --inplace "true" --exte
nsions "h,cpp,c,hlsl,hlsli" --exclude "extern include" "features/Complex\ Parallax\ Materials/Shaders/ComplexParallaxMaterials/ComplexParallaxMaterials.hlsli src/Features/DistantTreeLighting.cpp"

...to replicate as many clang-format-lint arguments used in this workflow (clang-format version, inplace, extensions, excludes), and succeeds:

Processing 2 files: features/Complex Parallax Materials/Shaders/ComplexParallaxMaterials/ComplexParallaxMaterials.hlsli, src/Features/DistantTreeLighting.cpp

This of course, requires any and all whitespaces in the filepaths to be escaped by a backslash character \, otherwise filepaths will be broken apart just as before.
E.g.:

python3 ../../clang-format-lint-action/run-clang-format.py --clang-format-executable /usr/bin/clang-format-16 --inplace "true" --extensions "h,cpp,c,hlsl,hlsli" --exclude "extern include" "features/Complex Parallax Materials/Shaders/ComplexParallaxMaterials/ComplexParallaxMaterials.hlsli src/Features/DistantTreeLighting.cpp"

will return:

Processing 4 files: features/Complex, Parallax, Materials/Shaders/ComplexParallaxMaterials/ComplexParallaxMaterials.hlsli, src/Features/DistantTreeLighting.cpp
run-clang-format.py: error: [Errno 2] No such file or directory: 'Parallax'
run-clang-format.py: error: [Errno 2] No such file or directory: 'features/Complex'
run-clang-format.py: error: [Errno 2] No such file or directory: 'Materials/Shaders/ComplexParallaxMaterials/ComplexParallaxMaterials.hlsli'

I was able to test these changes locally by testing the Python script alone, but I want to try testing these changes as a GitHub Action. Is there a way I can do this?


Please let me know if additional changes are required.
Thank you for considering these changes.

@DoozyX
Copy link
Owner

DoozyX commented Dec 21, 2023

Thanks, I am using https://github.com/DoozyX/test-action to test the action, can have the code copied from this repo as local action and test it using that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow Fails if Path provided in "Source" input contains whitespace
2 participants