Test precommit init command Setup: create a minimal OCaml project with git $ mkdir test-project $ cd test-project $ git init -q $ echo '(lang dune 3.0)' > dune-project Test dry-run mode shows what would be created $ precommit init --dry-run Would create $TESTCASE_ROOT/test-project/.git/hooks/ Would create $TESTCASE_ROOT/test-project/.git/hooks/pre-commit Would chmod +x $TESTCASE_ROOT/test-project/.git/hooks/pre-commit Would create $TESTCASE_ROOT/test-project/.git/hooks/commit-msg Would chmod +x $TESTCASE_ROOT/test-project/.git/hooks/commit-msg Would create ./.ocamlformat ℹ Would initialise . ✓ Processed 1 directory Test actual init creates the hooks $ precommit init ✓ Initialised . ✓ Processed 1 directory Verify hooks exist and are executable $ test -x .git/hooks/pre-commit && echo "pre-commit is executable" pre-commit is executable $ test -x .git/hooks/commit-msg && echo "commit-msg is executable" commit-msg is executable Verify pre-commit hook content $ head -2 .git/hooks/pre-commit #!/bin/sh # Auto-format OCaml files with dune before commit Verify commit-msg hook content $ head -2 .git/hooks/commit-msg #!/bin/sh # Check commit message for emojis and remove AI attribution lines Test error when not in a git repo $ cd /tmp $ mkdir no-git-$$ $ cd no-git-$$ $ echo '(lang dune 3.0)' > dune-project $ precommit init ✗ No git repositories found [1] Test error when not in an OCaml project $ cd /tmp $ mkdir no-dune-$$ $ cd no-dune-$$ $ git init -q $ precommit init ℹ No OCaml projects found (use --force to install anyway) [1]