Scope the pre-commit quality gate to the diff #6
Loading…
Reference in a new issue
No description provided.
Delete branch "docs/scope-the-quality-gate-to-the-diff"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A one-line change was paying for the whole gate. The "Before you commit" section
said all must pass and said nothing about when a check could be dropped, so the
honest reading was to run everything every time — minutes of hadolint, actionlint,
composer validateand both linters on a diff none of them could have noticed —and the tempting reading was to skip on a hunch.
Reduce by input, never by hope
A check may be dropped only when you can name the files it reads and show
git diff --name-only main...HEAD(plus anything uncommitted) touches none ofthem. Every lint here qualifies, because each one's input is a known glob:
composer validatecomposer.json,composer.locklint:yaml configconfig/**/*.{yaml,yml}lint:twig templatestemplates/**/*.twighadolint**/Dockerfile*actionlint.github/workflows/**There is no judgement left to exercise — the decision is a set intersection, which
is the point. "It's probably fine" is explicitly not a reason.
The coverage gate does not reduce
Deliberately excluded, and the reason is written down so it doesn't get relitigated:
100% is a property of the whole suite, not of the files you edited. A change in
src/is exercised by whichever tests happen to reach it, and a template edit canbreak any functional test that renders it, so there is no subset whose green proves
the gate.
--filterkeeps the role it already had — a fast signal while iterating,never a substitute for the one full run before committing.
The single exception is a docs-only diff, where the suite has no input at all
and the gate is the branch-name lint alone. That boundary is drawn exactly where
[skip ci]already draws it, and the same trap is flagged on both: a diff mixingdocs with any code, config or workflow change is not docs-only, however docs-like
it looks.
/vcs-check has to say what it skipped
A scopeable gate invites a specific false green — a summary reading "4 passed" when
three checks never ran. So the command now has to list the skipped checks with the
reason (
hadolint — no Dockerfile in the diff) next to the results, where thereader can disagree with it.
Verified
Docs-only change to two files, so the gate here is the branch-name lint and nothing
else — which is the rule this PR adds, applied to itself. Both files re-read for
the link anchor (
#scope-the-gate-to-the-diff) resolving against the new heading.