Skip to main content

Module dispatch

Module dispatch 

Source
Expand description

The two dispatchers.

They are NOT the same shape, and both shapes are load-bearing:

  • pre-commit runs its checks CONCURRENTLY and reports EVERY failure. Serial would be a visible slowdown on each commit; stopping at the first failure would hide the rest, so you’d fix one lint error, commit, and immediately meet the next.
  • pre-push runs them SERIALLY and stops at the FIRST failure, naming just that check. The steps are ordered and expensive (protected branch, then branch name, then rebase, then the whole test suite) and there is no point running tests after a rebase conflict.

Resist the tempting shared run_all helper — collapsing these is the obvious way to silently lose the distinction. tests/it/dispatchers.rs pins both.

Checks are FUNCTIONS in this binary, called directly. They used to be files: .git/hooks/pre-commit-*, each an identical sh shim whose only job was to re-exec this same binary and tell it its own name. One commit therefore cost 27 processes — a shim, the binary, then 13 more shims and 13 more binaries — to do work the binary already had in a table.

Deleting that removed the filename glob (order was lexicographic, so a rename could silently reorder a gate), the shebang emulation Windows needed because it cannot execute a #! script, and the spawn plumbing under both. Order is now a declared list in registry.

Enums§

Named
What run_named resolved a name to.
Named2
How a run name resolved.

Functions§

conventions_apply
Do this repository’s hooks apply the CONVENTIONS, or only the safety net?
enter_all_files_mode
Point every check at git ls-files instead of the index.
owed_audits
The dependency audits a push of refs owes (ADR-0018): opted in, and with no fresh record for the pushed commits in the push’s mode. Owed whatever the range touches, unlike scoped_push_gates.
pre_commit
pre_push
resolve_check_name
amont run <check> — one check by name. None when there is no such check, which the caller turns into a usage error.
run_all
amont run — every applicable check, on demand.
run_named
scoped_push_gates
The stamped pre-push gates (stamped_push_gate) — test suites, and declared heavy gates — that have work to do for a push that changed changed: what a rehearsal would run, and therefore what its stamp would have to name before a push may skip anything.
stamped_push_gate
Is check a push gate that runs before git connects, and is stamped for it (ADR-0018)? A scoped one, or a declared heavy one whatever its scope: a * declaration can be any command, and one that runs for a minute on the open connection is the failure ADR-0018 exists to stop (#414). The built-in unscoped checks (branch-protect, secrets) are light and need the push’s own refs, so they stay in the hook; the dependency audits answer through their own record.