Skip to content

Commit dbc2305

Browse files
authored
refactor: Docker run args (#185)
* refactor(check.sh): Split docker run args * feat(docker): Don't remove image between runs
1 parent 434716a commit dbc2305

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

check.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
###############################################################################
4-
# entrypoint.sh #
4+
# check.sh #
55
###############################################################################
66
# USAGE: ./entrypoint.sh [<path>] [<fallback style>]
77
#
@@ -21,9 +21,23 @@ format_diff() {
2121
local filepath="$1"
2222
# Invoke clang-format with dry run and formatting error output
2323
if [[ $CLANG_FORMAT_MAJOR_VERSION -gt "9" ]]; then
24-
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}")"
24+
local_format="$(docker run \
25+
--volume "$(pwd)":"$(pwd)" \
26+
--workdir "$(pwd)" \
27+
ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" \
28+
--dry-run \
29+
--Werror \
30+
--style=file \
31+
--fallback-style="$FALLBACK_STYLE" \
32+
"${filepath}")"
2533
else # Versions below 9 don't have dry run
26-
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}")"
34+
formatted="$(docker run \
35+
--volume "$(pwd)":"$(pwd)" \
36+
--workdir "$(pwd)" \
37+
ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" \
38+
--style=file \
39+
--fallback-style="$FALLBACK_STYLE" \
40+
"${filepath}")"
2741
local_format="$(diff -q <(cat "${filepath}") <(echo "${formatted}"))"
2842
fi
2943

0 commit comments

Comments
 (0)