docs/git-hooks.md
This repository uses prek for pre-commit hooks.
Install hooks with prek:
prek install
The pre-commit hook automatically runs before each commit and:
cargo fmt --all in the baml_language directory to automatically format codecargo clippy --fix to automatically fix clippy warnings where possiblecargo stow --check to validate workspace crate organizationIf there are issues that can't be auto-fixed, the commit will be aborted with instructions.
Note: Unlike the old hooks, prek does not auto-stage fixed files. If files are modified by the hooks, you'll need to git add them and commit again.
Sometimes you need to commit work-in-progress or have a valid reason to skip the checks:
git commit --no-verify -m "WIP: experimental changes"
SKIP=cargo-clippy git commit -m "message"
# or
PREK_SKIP=cargo-clippy git commit -m "message"
Supports comma-separated values for multiple hooks:
SKIP=cargo-clippy,cargo-fmt git commit -m "message"
# Run all hooks on all files
prek run --all-files
# Run a specific hook
prek run cargo-fmt --all-files
The hook automatically fixes most issues, but if it fails on clippy warnings that can't be auto-fixed:
Review the clippy output and fix the warnings manually. Common issues that need manual fixes:
If the hook isn't running:
prek install.git/hooks/pre-commit exists and is executableIf you need to disable hooks for your local development:
git config core.hooksPath /dev/null
To re-enable:
git config --unset core.hooksPath
prek install