summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2023-05-01 14:24:23 -0400
committerColin Walters <walters@verbum.org>2023-05-02 10:39:04 -0400
commitc1044a02b28982ef6dd58af98b23a40482d26487 (patch)
tree5402001ab710dadfd51ba3e9071b044016030e3e
parent453aed97f688c606622562145fa1f7c10096ba14 (diff)
downloadostree-c1044a02b28982ef6dd58af98b23a40482d26487.tar.gz
ci: Validate clang-format
-rwxr-xr-xci/codestyle.sh23
1 files changed, 17 insertions, 6 deletions
diff --git a/ci/codestyle.sh b/ci/codestyle.sh
index 850661e5..1db6c1f8 100755
--- a/ci/codestyle.sh
+++ b/ci/codestyle.sh
@@ -15,12 +15,23 @@ done
echo "ok"
fi
-# Will uncomment this once we reformat
-#if command -v clang-format; then
-# echo -n "checking clang-format... "
-# git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format --Werror --dry-run
-# echo "ok"
-#fi
+if command -v clang-format; then
+ clang_ver=$(clang-format --version)
+ clang_min_ver=15
+ version_re=" version ([0-9]+)."
+ if [[ $clang_ver =~ $version_re ]]; then
+ if test "${BASH_REMATCH[1]}" -ge "${clang_min_ver}"; then
+ echo -n "checking clang-format... "
+ git ls-files '**.c' '**.cxx' '**.h' '**.hpp' | xargs clang-format --Werror --dry-run
+ echo "ok"
+ else
+ echo "notice: clang-format ${clang_ver}" is too old
+ fi
+ else
+ echo "failed to parse clang-format version ${clang_ver}" 1>&2
+ exit 1
+ fi
+fi
echo -n 'grep-based static analysis... '
patterns=(glnx_fd_close)