Skip to content

Commit f1abfbe

Browse files
committed
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.
1 parent 44e907b commit f1abfbe

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.clang-format

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ UseTab: Always
44
BreakBeforeBraces: Linux
55
AllowShortIfStatementsOnASingleLine: false
66
IndentCaseLabels: false
7+
SortIncludes: CaseSensitive
8+
IncludeBlocks: Preserve

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ repos:
1818
- id: shellcheck
1919
args: [ -fgcc ]
2020

21+
- repo: https://github.com/pre-commit/mirrors-clang-format
22+
rev: v19.1.4
23+
hooks:
24+
- id: clang-format
25+
description: Runs formatting checks on the c code and and throws errors if suggestions
26+
are detected, without modifying the code. Style is defined in `.clang-format`. When
27+
encountering formatting-related errors, run `clang-format -i <path-to-file>` to make
28+
(destructively) the suggestions and evalute the resulting diff for more context.
29+
args: [ --dry-run, -Werror ]
30+
entry: clang-format
31+
types: [ c ]
32+
2133
- repo: local
2234
hooks:
2335
# Reimplementation of `make check-amount-access` for pygrep.

0 commit comments

Comments
 (0)