Add git hooks

Signed-off-by: CHatingPython <chatingpython@gmail.com>
This commit is contained in:
CHatingPython
2026-05-26 13:14:37 +02:00
committed by CHatingPython
parent 7017d83204
commit 4a58e97812
9 changed files with 70 additions and 43 deletions
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -e
BUILD_DIR="build"
echo "Running clang-format..."
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(cpp|hpp)$' || true)
if [ -z "$FILES" ]; then
echo "No C/C++ files to check"
exit 0
fi
for file in $FILES; do
clang-format -i "$file"
git add "$file"
done
echo "Running clang-tidy..."
for file in $FILES; do
clang-tidy \
"$file" \
-p "$BUILD_DIR"
done
echo "pre-commit checks passed"
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
BUILD_DIR="build"
echo "Building..."
cmake --build "$BUILD_DIR"
echo "Running tests..."
ctest --test-dir "$BUILD_DIR" --output-on-failure
echo "pre-push checks passed"