-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
47 lines (46 loc) · 1.63 KB
/
Copy pathlefthook.yml
File metadata and controls
47 lines (46 loc) · 1.63 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
commit-msg:
commands:
conventional-commit:
run: |
msg=$(head -n1 "{1}")
pattern='^(feat|fix|chore|refactor)(\([^()\s]+\))?!?: .+'
if ! echo "$msg" | grep -Pq "$pattern"; then
echo "Commit message must follow Conventional Commits format."
echo "Allowed types: feat, fix, chore, refactor"
echo "Examples: feat: add hook, fix(ci): correct preset, chore(cmake): bump version"
echo "Got: $msg"
exit 1
fi
pre-commit:
commands:
clang-format:
glob:
- "src/*.cpp"
- "src/*.h"
- "src/**/*.cpp"
- "src/**/*.h"
run: clang-format -i {staged_files}
stage_fixed: true
cmake-format:
glob:
- "CMakeLists.txt"
- "*.cmake"
- "**/*.cmake"
run: cmake-format -i {staged_files}
stage_fixed: true
check-trailing-whitespace:
run: if grep -IPrn '\s+$' {staged_files}; then exit 1; fi; exit 0
fail_text: "Trailing whitespace found"
check-eof-newline:
run: for f in {staged_files}; do grep -qI '' "$f" && [ -s "$f" ] && [ "$(tail -c1 "$f" | wc -l)" -eq 0 ] && echo "$f missing newline at EOF" && exit 1; done; exit 0
fail_text: "File(s) missing newline at end of file"
clang-tidy:
glob:
- "src/*.cpp"
- "src/**/*.cpp"
run: clang-tidy -p build/release-linux --warnings-as-errors='*' {staged_files}
fail_text: "clang-tidy reported issues (run ./scripts/build.sh first if compile_commands.json is missing)"
shellcheck:
glob: "scripts/*.sh"
run: shellcheck {staged_files}
fail_text: "shellcheck found issues"