Expand description
Shared plumbing for the linter-orchestration hooks.
Nine of them do the same four things: collect staged files of some kind, bail out if there are none, resolve a tool, run it. In shell that was ~65 lines apiece, mostly duplicated; here it is a handful of helpers and each hook keeps only what is actually specific to it.
Enums§
- Restaged
- What a re-stage actually did. THREE answers, because the old
boolconflated two of them and the conflation shipped unformatted code.
Functions§
- fail
- first_
existing - The first of
namesthat exists at the repo root — how these hooks decide a repo has opted into a tool. - fixing_
enabled - Whether the user asked for checks to repair what they find.
- fixing_
requested - What the CONFIG says, ignoring whether the current run may act on it.
- hl
- Orange, for the fragments these hooks highlight.
- not_
the_ index - Whether the file set every check sees is something other than the index.
- ok
- override_
file_ set - Make every subsequent
staged_filesanswer fromfilesinstead of the index. Only the first call counts. - program
- Resolve a tool name to a full path for spawning.
- repo_
root - Repo root, or “.” when git cannot say.
- repo_
root_ checked - Repo root, or an error naming the problem.
- resolve_
tool - Resolve a tool, preferring the repo’s PINNED copy so the hook matches CI.
- restage
- Re-stage exactly the paths a fixer rewrote, and say what happened.
- run
- Run
argvfromroot, inheriting stdio. True when it exits 0. - run_
quiet - As
run, but with the tool’s own output discarded. - staged_
files - An empty
extsreturns them all. - strip_
git_ env - Strip git’s own environment before handing a Command to another tool.
- warn
- which
- First match for
toolon PATH.