From 3182d79018402bd9fb8c21cf4da96df0e6f4be42 Mon Sep 17 00:00:00 2001 From: Se7enZ Date: Sun, 1 Dec 2024 13:15:25 +0100 Subject: [PATCH] chore: Add clang-format to pre-commit. Also intends to replace `make check-src-include-order` and `make check-hdr-include-order` by adding configuration to check for include ordering. --- .clang-format | 2 ++ .pre-commit-config.yaml | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.clang-format b/.clang-format index a3ef233a243d..bc97efc80c61 100644 --- a/.clang-format +++ b/.clang-format @@ -4,3 +4,5 @@ UseTab: Always BreakBeforeBraces: Linux AllowShortIfStatementsOnASingleLine: false IndentCaseLabels: false +SortIncludes: CaseSensitive +IncludeBlocks: Preserve diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f8cf87d5d369..99793dfc71d0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,6 +18,18 @@ repos: - id: shellcheck args: [ -fgcc ] +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.4 + hooks: + - id: clang-format + description: Runs formatting checks on the c code and and throws errors if suggestions + are detected, without modifying the code. Style is defined in `.clang-format`. When + encountering formatting-related errors, run `clang-format -i ` to make + (destructively) the suggestions and evalute the resulting diff for more context. + args: [ --dry-run, -Werror ] + entry: clang-format + types: [ c ] + - repo: local hooks: # Reimplementation of `make check-amount-access` for pygrep.