* Use a System clang-tidy When Available and Make --fix Converge in One Pass
scripts/run_clang_tidy.sh only looked at CLANG_TIDY and the venv it creates,
so a clang-tidy already on the system was never used. It is now the first
choice: the pinned version outright, another version after a prompt that
says results may differ slightly from CI, which -y and an existing pinned
venv skip.
Two problems in clang_tidy_diff.py made --fix need several runs and still
leave the plain check failing:
- A deleted #include orphans uses on unchanged lines. The plain check runs
such a file whole and reports them, but --fix kept the line filter to the
changed lines, so they were never fixed. Fix mode now runs the file whole
first and then fixes exactly the changed lines plus the lines that run
found wanting, so unrelated lines are still never rewritten.
- clang-tidy exits non-zero for the findings it just fixed, so every fixed
file was reported as failed and the user ran --fix again to see what was
left. A file --fix changed is now checked again and the fixed files are
listed separately from what --fix could not add.
CI runs the script without --fix and is unchanged.
* Keep the a/ b/ Diff Prefixes Whatever the User's Git Config Says
parse_diff recognises a changed file by its +++ b/ header. With
diff.noprefix or diff.mnemonicPrefix set, git prints +++ src/x.cpp or
+++ w/src/x.cpp instead, every file was dropped, and the local check
reported no changed C++ lines. The diff is now asked for the a/ and b/
prefixes outright, which overrides both settings.
* Warn When No Remote Points at OrcaSlicer/OrcaSlicer
Without one, run_clang_tidy.sh compares against origin/main. When origin
is a fork whose main already holds the commits, the check finds nothing
and says so, without hinting at why. The script now names the base it
fell back to and how to point it at the upstream repository.
run_clang_tidy.ps1 had not been run on Windows before.
- Run native commands through Invoke-Quiet. Under
$ErrorActionPreference = "Stop", Windows PowerShell made CMake's
first stderr line fatal, so configure always failed.
- Pass the --line-filter name with native separators. clang-tidy
matches it against the end of the file's native path, so on Windows
every misc-include-cleaner finding was dropped.
- Decode subprocess output as UTF-8 and let stdout replace characters
it cannot encode. A changed line with text such as 打印 crashed the
script under cp1252.
- Check VCToolsInstallDir and WindowsSdkDir in VsDevCmd's output
before applying it, so a failure names the command to run and leaves
the calling shell untouched.
- Log the git_commit_hash_header build, use -LiteralPath for logs, and
hide VsDevCmd's stderr as build_win.bat does.
On every platform, git quotes non-ASCII paths and appends a tab to a
+++ header whose path contains a space, and parse_diff dropped both.
changed_files and the workflow's changed-files step now pass
core.quotePath=false, and parse_diff strips the tab.
A Linux job configures without the precompiled header and runs clang-tidy over the C++ lines a pull request changes. The only check for now is misc-include-cleaner for missing includes; .clang-tidy is where further checks get enabled.
scripts/run_clang_tidy.sh (Linux, macOS) and scripts/run_clang_tidy.ps1 (Windows) run the same check locally: the same configure, the clang-tidy version pinned in scripts/clang_tidy_requirements.txt, and the same comparison against OrcaSlicer's main. They offer to install what is missing, or print the command to do it by hand.