From bd3b8186b983959f15404fac48cabdcfa57d51ba Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Wed, 16 Jul 2025 04:18:27 +0200 Subject: [PATCH] Fix Docker wrapper to handle relative paths --- .github/workflows/format-check-new.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/format-check-new.yml b/.github/workflows/format-check-new.yml index c26efe14e..d14207d47 100644 --- a/.github/workflows/format-check-new.yml +++ b/.github/workflows/format-check-new.yml @@ -14,8 +14,25 @@ jobs: - name: Setup clang-format Docker alias run: | # Create a wrapper script for clang-format that uses Docker - echo '#!/bin/bash' | sudo tee /usr/local/bin/clang-format - echo 'docker run --rm -i -v "$PWD":"$PWD" -w "$PWD" silkeh/clang:18 clang-format "$@"' | sudo tee -a /usr/local/bin/clang-format + cat > /tmp/clang-format-wrapper << 'EOF' + #!/bin/bash + # Convert relative paths to absolute paths and run clang-format in Docker + args=() + for arg in "$@"; do + if [[ "$arg" == /* ]] || [[ "$arg" == -* ]]; then + # Absolute path or option, use as-is + args+=("$arg") + elif [[ -e "$arg" ]]; then + # Relative path that exists, convert to absolute + args+=("$(realpath "$arg")") + else + # Not a file path, use as-is + args+=("$arg") + fi + done + docker run --rm -i -v "$PWD":"$PWD" -w "$PWD" silkeh/clang:18 clang-format "${args[@]}" + EOF + sudo mv /tmp/clang-format-wrapper /usr/local/bin/clang-format sudo chmod +x /usr/local/bin/clang-format # Verify version clang-format --version