ci: let pre-commit own git hooks (disable trunk hook actions) - #207
Merged
Conversation
Trunk was the git-hooks manager (core.hooksPath -> trunk's cache), so pre-commit's framework hook -- which owns clang-format -- never ran on commit and new C++ files landed unformatted. Disable trunk's three git-hook actions (trunk-announce, trunk-check-pre-push, trunk-fmt-pre-commit) so trunk stops claiming core.hooksPath; pre-commit then owns .git/hooks via `pre-commit install`. Trunk still runs standalone via `trunk check` and the CI trunk job. Also carries routine trunk linter version bumps (checkov, prettier, trivy, trufflehog) and adds -std=c++20 to the .clangd compile flags.
Add a step to the CI `trunk` job that fails if trunk could seize the git hooks from pre-commit: it rejects any enabled trunk git-hook action in .trunk/trunk.yaml and, when trunk is available, syncs hooks and requires core.hooksPath not point into trunk's cache. This is the only place the check is reliable: a pre-commit hook can't run if trunk owns the hook path, and a trunk custom linter runs in an isolated sandbox blind to the real git config.
Fab-Cat
approved these changes
Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
clang-formatwasn't auto-formatting new C++ files locally. Root cause: trunk was the git-hooks manager —core.hooksPathpointed at trunk's cache, so pre-commit's framework hook (which ownsclang-format) could never install or run on commit, and trunk's own commit hook runstrunk fmt, which by design excludesclang-format. New files landed with 4-space indent.Fix
Disable trunk's three git-hook actions so trunk stops claiming
core.hooksPath:trunk-announce,trunk-check-pre-push,trunk-fmt-pre-commit→actions.disabledWith those off,
trunk git-hooks syncreports "not managing your git hooks" andpre-commit installcan own.git/hooks/{pre-commit,pre-push}. Trunk still runs standalone viatrunk checkand the CItrunkjob. Verified: after the change, realgit commits run the pre-commit hooks (both commits in this PR did).Per-clone step: run
pre-commit install(was blocked before because trunk heldcore.hooksPath).Regression guard
A CI step in the
trunkjob asserts trunk never re-seizes the hooks — it rejects any enabled trunk git-hook action in.trunk/trunk.yamland, when trunk is present, syncs hooks and requirescore.hooksPathnot point into trunk's cache. This is the only place the check is reliable: a pre-commit hook can't run if trunk owns the hook path, and a trunk custom linter runs in an isolated sandbox blind to the real git config (both were tried and don't work).Also included (staged)
.clangd: add-std=c++20to the clangd compile flags..trunk/trunk.yaml: routine linter version bumps (checkov, prettier, trivy, trufflehog).