Skip to content

Add a canonical pre-commit clang-format config for the Tap family#2

Merged
tap merged 1 commit into
mainfrom
claude/pre-commit-hooks
Jul 19, 2026
Merged

Add a canonical pre-commit clang-format config for the Tap family#2
tap merged 1 commit into
mainfrom
claude/pre-commit-hooks

Conversation

@tap

@tap tap commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Why

A clang-format CI failure should never leave a developer's machine — but there was no shared way to run the format check locally before pushing. This adds pre-commit to TapHouse so every Tap repo catches formatting at git commit, at the same pinned clang-format version as CI.

What

A fourth canonical file, .pre-commit-config.yaml, distributed and guarded exactly like the others:

  • .pre-commit-config.yaml (new) — pins the official pre-commit/mirrors-clang-format hook at v18.1.3 (the Tap-wide clang-format version, matching CI), scoped types_or: [c, c++] and exclude: '^third_party/'.
  • scripts/sync.sh — copies it into consumers alongside .clang-format / .clang-tidy / STYLE.md.
  • .github/workflows/drift-check.yml — diffs it too, so a consumer's copy can't silently diverge.
  • README.md — adoption steps (pre-commit install), the "run the same hook in CI via pre-commit run" note, and the two version knobs (the TapHouse tag vs the mirror rev).

Design notes

  • One pinned version, no drift. The mirror rev is the clang-format version for the whole family, set once here and carried to every repo by sync.sh. Consumer CI runs pre-commit run --all-files instead of a separately-installed clang-format, so local and CI share one version by construction — the exact skew that makes an ad-hoc hook worse than none.
  • Mirror, not a TapHouse package. Self-hosting the hook (repo: tap/taphouse) would require making TapHouse a pip-installable package — which just reimplements mirrors-clang-format and pulls clang-format from the same PyPI wheel anyway. Referencing the upstream mirror is the same guarantee with less machinery; the pin still lives here, in the synced config.
  • clang-format only. clang-tidy stays a CI concern (it needs a compile database and per-TU exclusion of vendored sources, per the existing enforcement notes) — the hook is the fast, compile-free layout layer.

Validation

Ran the config against the MuTap tree: the mirror's clang-format v18.1.3 produces byte-identical output to ubuntu's apt clang-format-18 on every CI-checked file (zero diff) — confirming no local/CI skew. The only files it additionally flags are ones MuTap's CI list doesn't currently cover (a coverage gap the broader hook would close on adoption).

Bump this repo to v3 on merge so consumers can pin ref: v3.

Rollout (follow-up, per consumer)

sync.sh the new config into mutap / mutap-max / sampleratetap, pre-commit install, switch each repo's clang-format CI job to pre-commit run --all-files, and bump the drift ref: to v3.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TLE2rvptWxV8catE8vTvgx


Generated by Claude Code

Formatting failures that CI catches should never leave a developer's machine.
Adds .pre-commit-config.yaml as a fourth canonical TapHouse file: it pins the
official pre-commit/mirrors-clang-format hook at v18.1.3 (the Tap-wide
clang-format version, matching CI), scoped to C/C++ and excluding third_party.

Distributed like the other configs — sync.sh copies it in, drift-check.yml
guards it — so every Tap repo runs the same hook at the same pinned version.
Consumer CI should run `pre-commit run --all-files` instead of a
separately-installed clang-format, making local and CI share one version by
construction (verified: mirror v18.1.3 == ubuntu apt clang-format-18 on the
MuTap tree, byte-for-byte).

We reference the upstream mirror rather than republishing clang-format as a
TapHouse Python package: both pull the same pinned wheel from PyPI, so the
mirror is the same guarantee with less machinery, and the pin still lives here.
clang-tidy stays a CI concern (it needs a compile DB and per-TU vendored
exclusion) — the hook is the fast, layout-only layer.

- .pre-commit-config.yaml: canonical consumer config (pins the mirror rev)
- scripts/sync.sh, .github/workflows/drift-check.yml: add it to the synced set
- README.md: adoption steps, the CI-runs-pre-commit note, the two version knobs

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TLE2rvptWxV8catE8vTvgx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants