tools: add run_clang_tidy_common.sh to apply clang-tidy fixes for Lts/Common
This commit is contained in:
1 parent
5c1896a930
commit
0d5990f127
1 file changed
+36
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
echo "Ensuring clang-tidy and clang-format are installed"
|
||||
apt-get update
|
||||
apt-get install -y clang-tidy clang-format || true
|
||||
|
||||
BUILD_DIR=/repo/build_migrate_Lts_Common
|
||||
if [ ! -f "$BUILD_DIR/compile_commands.json" ]; then
|
||||
echo "Regenerating compile_commands.json"
|
||||
cmake -S /repo -B $BUILD_DIR -G Ninja -DCMAKE_PREFIX_PATH=/opt/Qt/6.8.3/gcc_64 -DCMAKE_CXX_STANDARD=20 -DMIGRATE_MODULE=Lts/Common -DBUILD_TESTING=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
fi
|
||||
|
||||
echo "Running clang-tidy (safe modernize checks)"
|
||||
CHECKS="modernize-*,-modernize-use-trailing-return-type,-modernize-raw-string-literal"
|
||||
|
||||
# Process each C/C++ source/header under Lts/Common
|
||||
git ls-files Lts/Common | grep -E '\.(cpp|cc|cxx|h|hpp)$' | while read -r f; do
|
||||
echo "clang-tidy $f"
|
||||
clang-tidy "$f" -p "$BUILD_DIR" -checks="$CHECKS" --format-style=file -fix -quiet || true
|
||||
done
|
||||
|
||||
# Format any modified files
|
||||
git ls-files -m | grep '^Lts/Common' | while read -r f; do
|
||||
echo "clang-format $f"
|
||||
clang-format -i "$f" || true
|
||||
done
|
||||
|
||||
# Commit changes if any
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add Lts/Common || true
|
||||
git commit -m "migrate(Lts/Common): apply clang-tidy modernization fixes\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" || true
|
||||
fi
|
||||
|
||||
echo "Done. Modified files:"
|
||||
git status --porcelain
|
||||
Reference in new issue
Block a user