# precommit Pre-commit hook initialization for OCaml projects. ## Overview This tool sets up git hooks directly for OCaml projects (no Python required): - **pre-commit hook**: Automatically formats OCaml code using `dune fmt` - **commit-msg hook**: Removes Claude co-author lines and rejects emojis in commit messages - **.ocamlformat**: Creates a default `.ocamlformat` file if missing ## Installation Install with opam: ```sh $ opam install precommit ``` If opam cannot find the package, it may not yet be released in the public `opam-repository`. Add the overlay repository, then install it: ```sh $ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git $ opam update $ opam install precommit ``` ## Usage ### Initialize hooks Run in an OCaml project directory (where `dune-project` exists): ```sh $ precommit init ``` This creates: - `.git/hooks/pre-commit` - Runs `dune fmt` on staged OCaml files - `.git/hooks/commit-msg` - Filters commit messages - `.ocamlformat` - Default ocamlformat configuration (if missing) ### Check status ```sh $ precommit status ``` Shows which hooks are installed. Exit code is 1 if any OCaml project is missing hooks or `.ocamlformat`. ### Check git history ```sh $ precommit check ``` Scans git history for commits with AI attribution patterns. ### Recursive operation Use `-r` to operate on all OCaml projects in subdirectories: ```sh $ precommit init -r $ precommit status -r $ precommit check -r ``` ### Dry run To see what would be created without making changes: ```sh $ precommit init --dry-run ``` ## Requirements - git - dune (for code formatting) ## Licence MIT License. See [LICENSE.md](LICENSE.md) for details.