Skip to main content

PRE_COMMIT_BODY

Constant PRE_COMMIT_BODY 

Source
pub const PRE_COMMIT_BODY: &str = "#!/bin/sh\n# Managed by `drep init`.\n# Runs the linters this repo configures, and an LLM review of the staged code.\nif ! command -v drep > /dev/null 2>&1; then\n    echo \"drep: not found on PATH; refusing to let the commit through unreviewed.\" >&2\n    exit 1\nfi\ndrep lint-docs --staged --fail-on error || exit $?\nexec drep check --staged\n";
Expand description

The body drep writes for pre-commit.

Two commands, in this order. lint-docs is rule-based and takes ~10 ms, so an obvious documentation defect does not cost an LLM round trip; check sends the staged code to a model and is the expensive half.

--fail-on error rather than --strict: under the severity scale the doc checks use, --strict blocks on any finding, which over a real repository is dominated by line length and trailing whitespace. Measured on drep’s own tree that is 75 findings, none above info. A hook that blocks a commit over a long line is a hook that gets deleted. error is one check - an unclosed fence, which renders the rest of the document as code.

exec on the last command is what keeps the LLM client’s exit status, which is what aborts the commit when a finding gates it. The first command cannot be execed, so its status is propagated explicitly.