From 74c61d7deaf95d14bf33345d2c966b645078cded Mon Sep 17 00:00:00 2001 From: jidicula Date: Sun, 24 Dec 2023 12:28:20 -0500 Subject: [PATCH] refactor(check.sh): Split docker run args --- check.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/check.sh b/check.sh index 4ea3929..1d25739 100755 --- a/check.sh +++ b/check.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash ############################################################################### -# entrypoint.sh # +# check.sh # ############################################################################### # USAGE: ./entrypoint.sh [] [] # @@ -21,9 +21,25 @@ format_diff() { local filepath="$1" # Invoke clang-format with dry run and formatting error output if [[ $CLANG_FORMAT_MAJOR_VERSION -gt "9" ]]; then - local_format="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" -n --Werror --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" + local_format="$(docker run \ + --volume "$(pwd)":"$(pwd)" \ + --workdir "$(pwd)" \ + --rm \ + ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" \ + --dry-run \ + --Werror \ + --style=file \ + --fallback-style="$FALLBACK_STYLE" \ + "${filepath}")" else # Versions below 9 don't have dry run - formatted="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" + formatted="$(docker run \ + --volume "$(pwd)":"$(pwd)" \ + --workdir "$(pwd)" \ + --rm \ + ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" \ + --style=file \ + --fallback-style="$FALLBACK_STYLE" \ + "${filepath}")" local_format="$(diff -q <(cat "${filepath}") <(echo "${formatted}"))" fi