My own corner of monopam
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 92 lines 1.9 kB view raw view rendered
1# precommit 2 3Pre-commit hook initialization for OCaml projects. 4 5## Overview 6 7This tool sets up git hooks directly for OCaml projects (no Python required): 8- **pre-commit hook**: Automatically formats OCaml code using `dune fmt` 9- **commit-msg hook**: Removes Claude co-author lines and rejects emojis in commit messages 10- **.ocamlformat**: Creates a default `.ocamlformat` file if missing 11 12## Installation 13 14Install with opam: 15 16<!-- $MDX skip --> 17```sh 18$ opam install precommit 19``` 20 21If opam cannot find the package, it may not yet be released in the public 22`opam-repository`. Add the overlay repository, then install it: 23 24<!-- $MDX skip --> 25```sh 26$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git 27$ opam update 28$ opam install precommit 29``` 30 31## Usage 32 33### Initialize hooks 34 35Run in an OCaml project directory (where `dune-project` exists): 36 37<!-- $MDX non-deterministic=command --> 38```sh 39$ precommit init 40``` 41 42This creates: 43- `.git/hooks/pre-commit` - Runs `dune fmt` on staged OCaml files 44- `.git/hooks/commit-msg` - Filters commit messages 45- `.ocamlformat` - Default ocamlformat configuration (if missing) 46 47### Check status 48 49<!-- $MDX non-deterministic=command --> 50```sh 51$ precommit status 52``` 53 54Shows which hooks are installed. Exit code is 1 if any OCaml project is missing hooks or `.ocamlformat`. 55 56### Check git history 57 58<!-- $MDX non-deterministic=command --> 59```sh 60$ precommit check 61``` 62 63Scans git history for commits with AI attribution patterns. 64 65### Recursive operation 66 67Use `-r` to operate on all OCaml projects in subdirectories: 68 69<!-- $MDX non-deterministic=command --> 70```sh 71$ precommit init -r 72$ precommit status -r 73$ precommit check -r 74``` 75 76### Dry run 77 78To see what would be created without making changes: 79 80<!-- $MDX non-deterministic=command --> 81```sh 82$ precommit init --dry-run 83``` 84 85## Requirements 86 87- git 88- dune (for code formatting) 89 90## Licence 91 92MIT License. See [LICENSE.md](LICENSE.md) for details.