OSDN Git Service

[Fix] clang-format の実行でエラーが起きたとき整形チェックをエラーとする
authorHabu <habu1010+github@gmail.com>
Mon, 5 Sep 2022 13:08:48 +0000 (22:08 +0900)
committerHabu <habu1010+github@gmail.com>
Mon, 5 Sep 2022 13:16:16 +0000 (22:16 +0900)
clang-format コマンドが正しく実行されたかどうかチェックしていなかったため、
clang-format のインストールに失敗した場合にソースコード整形チェックを素通りしてしま
っていた。
clang-format コマンドの実行でエラーが発生した場合はスクリプトもそのエラーコードで終了
するようにする。

.github/scripts/check-format.sh

index 4025ba8..53ed8d5 100644 (file)
@@ -23,6 +23,12 @@ sudo apt-get install clang-format-15 >/dev/null
 SRC_FILES=$(find src/ -name \*.cpp -or -name \*.h)
 
 clang-format-15 -style=file:.github/scripts/check-clang-format-style -i $SRC_FILES
+clang_format_result=$?
+
+if [ $clang_format_result -ne 0 ]; then
+    echo "Could not execute clang-format properly."
+    exit $clang_format_result
+fi
 
 DIFF_FILE=$(mktemp)
 git diff >$DIFF_FILE