Skip to content

Commit

Permalink
refactor: Docker run args (#185)
Browse files Browse the repository at this point in the history
* refactor(check.sh): Split docker run args

* feat(docker): Don't remove image between runs
  • Loading branch information
jidicula committed Mar 12, 2024
1 parent 434716a commit dbc2305
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions check.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

###############################################################################
# entrypoint.sh #
# check.sh #
###############################################################################
# USAGE: ./entrypoint.sh [<path>] [<fallback style>]
#
Expand All @@ -21,9 +21,23 @@ 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)" \
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)" \
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 dbc2305

Please sign in to comment.