-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
51 lines (48 loc) · 1.48 KB
/
.pre-commit-config.yaml
File metadata and controls
51 lines (48 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: check-added-large-files
args:
- --maxkb=2048
- id: check-merge-conflict
- repo: https://github.com/gitleaks/gitleaks
rev: v8.28.0
hooks:
- id: gitleaks
# CPP hooks
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v20.1.8
hooks:
- id: clang-format
types_or: [c++, c, cuda]
- repo: local
hooks:
- id: clang-tidy
name: clang-tidy
description: C++ code analysis tool
language: system
types_or: [c++, c, cuda]
always_run: false
pass_filenames: true
entry: bash -c
args:
- |
# If pre-commit passed no files, do nothing (success).
if [ "$#" -eq 0 ]; then
exit 0
fi
# Find compile_commands.json by searching up from current directory
d="$PWD"
while [ "$d" != "/" ]; do
if [ -f "$d/build/compile_commands.json" ]; then
# Run clang-tidy and ignore PCH-related errors
clang-tidy -p "$d/build" "$@" 2>&1 | grep -v "is not a valid precompiled PCH file" | grep -v "is not a PCH file:" || true
exit 0
fi
d="$(dirname "$d")"
done
echo "Error: compile_commands.json not found. Build the project first." >&2
exit 1
- --