From dc41dbd9548b4ab2077680ced2c03d4ce962cfa5 Mon Sep 17 00:00:00 2001 From: yhirose Date: Mon, 7 Sep 2026 17:18:45 -0400 Subject: [PATCH] Pin style-check and pre-commit to clang-format 23.1.0 CI relied on ubuntu-latest's default apt clang-format (18.1.3), while the pre-commit hook was pinned to a different 18.x build. Neither tracked a specific, deliberately-chosen version, and the two could drift from each other and from whatever a contributor has installed locally. Both now pin the same clang-format 23.1.0 (latest stable), installed via pipx in CI. Also scope the pre-commit hook's file matcher to the same set of files test/Makefile's style_check target checks, since the previous \.(cpp|cc|h)$ pattern reached into vendored code (test/gtest, benchmark/crow) that must stay untouched. Reformat httplib.h's brace-init spacing to match 23.1.0's output. --- .github/workflows/test.yaml | 4 ++++ .pre-commit-config.yaml | 4 ++-- httplib.h | 8 +++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5b9ac22..27ed77d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -37,6 +37,10 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + - name: install clang-format + run: | + pipx install clang-format==23.1.0 + echo "$HOME/.local/bin" >> "$GITHUB_PATH" - name: run style check run: | clang-format --version diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0c3e543..f7a8665 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 # 最新バージョンを使用 + rev: v23.1.0 # CIのstyle-checkと同じバージョンに揃える hooks: - id: clang-format - files: \.(cpp|cc|h)$ + files: ^(httplib\.h|(example|fuzzing|test)/[^/]+\.(cpp|cc|h))$ args: [-i] # インプレースで修正 \ No newline at end of file diff --git a/httplib.h b/httplib.h index 355ff41..7db99a0 100644 --- a/httplib.h +++ b/httplib.h @@ -6881,12 +6881,10 @@ inline int getaddrinfo_with_timeout(const char *node, const char *service, // actually finish before letting the stack frame go. The trade-off is that // a wedged DNS server can hold this thread for the system resolver timeout // (~30s by default) past the caller's connection timeout. - struct gaicb request {}; + struct gaicb request{}; struct gaicb *requests[1] = {&request}; - struct sigevent sevp {}; - struct timespec timeout { - timeout_sec, 0 - }; + struct sigevent sevp{}; + struct timespec timeout{timeout_sec, 0}; request.ar_name = node; request.ar_service = service;