DoozyX / clang-format-lint-action

This action checks if the source code matches the .clang-format file.
MIT License
129 stars 46 forks source link

Allow directories with white-spaces to be passed #63

Closed rjwignar closed 6 months ago

rjwignar commented 7 months ago

This fixes #62

Summary of Changes

run-clang-format.py:

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 commented 6 months ago

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.