Skip to content

Commit 062f366

Browse files
authored
fix: Explicitly use major version (#135)
Resolves: #134
1 parent 523c716 commit 062f366

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ GitHub Action for `clang-format` checks. Note that this Action does **NOT** form
88

99
You can define your own formatting rules in a `.clang-format` file at your repository root, or you can provide a fallback style (see [`fallback-style`](#inputs)). You can also provide a path to check. If you want to run checks against multiple paths in your repository, you can use this Action in a [matrix run](#multiple-paths).
1010

11-
## Versions supported
12-
* `clang-format-3.9`
13-
* `clang-format-4.0`
14-
* `clang-format-5.0`
15-
* `clang-format-6.0`
16-
* `clang-format-7`
17-
* `clang-format-8`
18-
* `clang-format-9`
19-
* `clang-format-10`
20-
* `clang-format-11`
21-
* `clang-format-12`
22-
* `clang-format-13`
23-
* `clang-format-14`
24-
* `clang-format-15`
11+
## Major versions supported
12+
* 3: `clang-format-3.9`
13+
* 4: `clang-format-4.0`
14+
* 5: `clang-format-5.0`
15+
* 6: `clang-format-6.0`
16+
* 7: `clang-format-7`
17+
* 8: `clang-format-8`
18+
* 9: `clang-format-9`
19+
* 10: `clang-format-10`
20+
* 11: `clang-format-11`
21+
* 12: `clang-format-12`
22+
* 13: `clang-format-13`
23+
* 14: `clang-format-14`
24+
* 15: `clang-format-15`
2525

2626
## Do you find this useful?
2727

2828
You can sponsor me [here](https://github.com/sponsors/jidicula)!
2929

3030
## Inputs
31-
* `clang-format-version` [optional]: The version of `clang-format` that you want to run on your codebase.
31+
* `clang-format-version` [optional]: The major version of `clang-format` that you want to run on your codebase.
3232
* Default: `13`
3333
* Available versions: see [Versions supported](#versions-supported)
3434
* `check-path` [optional]: The path to the directory in the repo that should be checked for C/C++/Protobuf formatting.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ branding:
77

88
inputs:
99
clang-format-version:
10-
description: 'The version of clang-format that you want to use.'
10+
description: 'The major version of clang-format that you want to use.'
1111
required: false
1212
default: '13'
1313
check-path:

check.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
###############################################################################
66
# USAGE: ./entrypoint.sh [<path>] [<fallback style>]
77
#
8-
# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c, .C,
9-
# .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path
8+
# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c,
9+
# .C, .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path
1010
# (arg1) for conforming to clang-format. If no path is provided or provided path
11-
# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files are
12-
# incorrectly formatted, the script lists them and exits with 1.
11+
# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files
12+
# are incorrectly formatted, the script lists them and exits with 1.
1313
#
1414
# Define your own formatting rules in a .clang-format file at your repository
1515
# root. Otherwise, the provided style guide (arg2) is used as a fallback.
@@ -20,10 +20,10 @@
2020
format_diff() {
2121
local filepath="$1"
2222
# Invoke clang-format with dry run and formatting error output
23-
if [[ $CLANG_FORMAT_VERSION -gt "9" ]]; then
24-
local_format="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_VERSION" -n --Werror --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")"
23+
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}")"
2525
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_VERSION" --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")"
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}")"
2727
local_format="$(diff -q <(cat "${filepath}") <(echo "${formatted}"))"
2828
fi
2929

@@ -41,7 +41,7 @@ format_diff() {
4141
return 0
4242
}
4343

44-
CLANG_FORMAT_VERSION="$1"
44+
CLANG_FORMAT_MAJOR_VERSION="$1"
4545
CHECK_PATH="$2"
4646
FALLBACK_STYLE="$3"
4747
EXCLUDE_REGEX="$4"

0 commit comments

Comments
 (0)