[OCaml] Mobile-friendly clone of cgit.
1
{
2
"version":"v1",
3
"hooks":[
4
{
5
"name":"Auto-format before git commit",
6
"trigger":"PreToolUse",
7
"matcher":"execute_bash",
8
"action":{
9
"type":"command",
10
"command":"#!/bin/bash\nINPUT=$(cat)\nCOMMAND=$(echo \"$INPUT\" | python3 -c \"import sys,json; print(json.load(sys.stdin).get('tool_input',{}).get('command',''))\" 2>/dev/null)\nif ! echo \"$COMMAND\" | grep -qE 'git\\s+(commit|\\-c .* commit)'; then\n exit 0\nfi\ncd /home/blendux/git/ogit\nOUTPUT=$(opam exec -- dune fmt 2>&1)\nRC=$?\nif [ $RC -eq 0 ]; then\n echo 'Formatting clean — proceeding with commit.'\n exit 0\nfi\n# dune fmt exit 1 means it reformatted files; run again to confirm stable\nOUTPUT2=$(opam exec -- dune fmt 2>&1)\nRC2=$?\nif [ $RC2 -eq 0 ]; then\n CHANGED=$(git diff --name-only)\n if [ -n \"$CHANGED\" ]; then\n git add $CHANGED\n echo \"Reformatted and staged: $CHANGED\"\n fi\n exit 0\nelse\n echo \"dune fmt produced unstable output — blocking commit.\" >&2\n exit 2\nfi",
11
"timeout":30
12
}
13
}
14
]
15
}
16