Installs pre-commit hooks for OCaml projects that run dune fmt automatically
1
fork

Configure Feed

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

Consolidate duplicate hex utilities and crypto functions

- Replace local hex_of_string/string_of_hex with ohex in tests:
- ocaml-spake2/test/test_spake2.ml
- ocaml-matter/test/test_tlv.ml
- ocaml-cbort/test/test_cbort.ml

- Make pase.ml re-export Crypto.sha256/hmac_sha256 instead of duplicating

- Remove odoc-xo rules from ocaml-yamlrw/doc/dune

- Apply ocamlformat to yamlrw, yamlt, bytesrw-eio

+53
+53
test/init.t
··· 1 + Test precommit init command 2 + 3 + Setup: create a minimal OCaml project with git 4 + $ mkdir test-project 5 + $ cd test-project 6 + $ git init -q 7 + $ echo '(lang dune 3.0)' > dune-project 8 + 9 + Test dry-run mode shows what would be created 10 + $ precommit init --dry-run 11 + Would create .git/hooks/ 12 + Would create .git/hooks/pre-commit 13 + Would chmod +x .git/hooks/pre-commit 14 + Would create .git/hooks/commit-msg 15 + Would chmod +x .git/hooks/commit-msg 16 + 17 + Test actual init creates the hooks 18 + $ precommit init 19 + Pre-commit hooks initialized successfully. 20 + 21 + Verify hooks exist and are executable 22 + $ test -x .git/hooks/pre-commit && echo "pre-commit is executable" 23 + pre-commit is executable 24 + $ test -x .git/hooks/commit-msg && echo "commit-msg is executable" 25 + commit-msg is executable 26 + 27 + Verify pre-commit hook content 28 + $ head -2 .git/hooks/pre-commit 29 + #!/bin/sh 30 + # Auto-format OCaml files with dune before commit 31 + 32 + Verify commit-msg hook content 33 + $ head -2 .git/hooks/commit-msg 34 + #!/bin/sh 35 + # Check commit message for emojis and remove Claude attribution lines 36 + 37 + Test error when not in a git repo 38 + $ cd /tmp 39 + $ mkdir no-git-$$ 40 + $ cd no-git-$$ 41 + $ echo '(lang dune 3.0)' > dune-project 42 + $ precommit init 43 + Error: No .git directory found. Run this from a git repository. 44 + [1] 45 + 46 + Test error when not in an OCaml project 47 + $ cd /tmp 48 + $ mkdir no-dune-$$ 49 + $ cd no-dune-$$ 50 + $ git init -q 51 + $ precommit init 52 + Error: No dune-project found. Run this from an OCaml project root. 53 + [1]