27 lines
562 B
Bash
Executable File
27 lines
562 B
Bash
Executable File
#!/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
|
|
|
|
git diff -U0 --cached | \
|
|
python3 <(curl -s https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang/tools/clang-format/clang-format-diff.py) -p1 -i
|
|
|
|
echo "Running clang-tidy..."
|
|
|
|
for file in $FILES; do
|
|
clang-tidy \
|
|
"$file" \
|
|
-p "$BUILD_DIR"
|
|
done
|
|
|
|
echo "pre-commit checks passed" |