Skip to main content

Module pre_commit_detect

Module pre_commit_detect 

Source
Expand description

Detect which pre-commit hook framework, if any, is wired into a project.

The detector is read-only: it inspects filesystem markers under the project root and returns a PreCommitSystem enum value. It never installs anything, modifies files, or contacts the network.

Detection order (deterministic; later checks only run if earlier checks did not match):

  1. Prek.pre-commit-config.yaml is present AND a prek-specific marker is present (prek resolvable on PATH, a mise.toml mentioning prek, or a prek: toolchain hint inside .pre-commit-config.yaml).
  2. PreCommit.pre-commit-config.yaml exists but no prek marker is present.
  3. Husky.husky/ directory exists at the project root, OR package.json contains a top-level husky key.
  4. Lefthook — any of lefthook.{yml,yaml} or .lefthook.{yml,yaml} exists at the project root.
  5. None — no markers found.

Used by the ito init advisory for explicit downstream hook setup.

Enums§

PreCommitSystem
The pre-commit hook framework detected in a project.

Functions§

detect_pre_commit_system
Detect the pre-commit framework wired into the project at project_root.