Skip to content

Commit

Permalink
refactor(check.sh): Split docker run args
Browse files Browse the repository at this point in the history
  • Loading branch information
jidicula committed Dec 24, 2023
1 parent 1b1eeea commit 74c61d7
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions check.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

###############################################################################
# entrypoint.sh #
# check.sh #
###############################################################################
# USAGE: ./entrypoint.sh [<path>] [<fallback style>]
#
Expand All @@ -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

Expand Down

0 comments on commit 74c61d7

Please sign in to comment.