Fix the clang-tidy check on Windows and for unusual file paths (#16163)

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.
This commit is contained in:
Kris Austin
2026-10-06 00:35:03 +08:00
committed by GitHub
parent 1496906939
commit c1e6de7e4e
4 changed files with 86 additions and 14 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ jobs:
- name: Look for changed C++ files
id: changes
run: |
if git diff --name-only HEAD^1 -- src tests | grep -qE '\.(cpp|cc|cxx|hpp|h|hxx)$'; then
if git -c core.quotePath=false diff --name-only HEAD^1 -- src tests | grep -qE '\.(cpp|cc|cxx|hpp|h|hxx)$'; then
echo "cpp=true" >> "$GITHUB_OUTPUT"
else
echo "No C++ changes under src/ or tests/."