Git Hook Setup Scripts#
This directory contains scripts to set up git hooks for OCaml projects.
setup-hooks.sh#
This script installs pre-commit and commit-msg hooks that ensure code quality before commits.
What the hooks do:#
Pre-commit hook:
- Dune build - Ensures the project builds successfully
- Dune fmt - Checks and enforces code formatting
- Dune test - Runs all tests
- Merlint - Runs the project's own merlint linter (if available)
- Prune - Checks for unused code in lib/ and bin/ directories (if prune is installed)
Commit-msg hook:
- Checks for AI attributions in commit messages and rejects them
Installation#
Run from the project root:
./scripts/setup-hooks.sh
Notes#
- The hooks are installed in
.git/hooks/which is not tracked by git - You need to run the setup script on each clone of the repository
- To bypass the pre-commit hook in emergencies:
git commit --no-verify - The script uses the project's own merlint via
dune exec -- merlint - For the merlint project itself: Use
--no-verifyuntil we migrate from Printf to Fmt