I’m on Windows, and Sublime Merge is set to use system git.
I created file ~/.config/git/hooks/prepare-commit-msg:
#!/bin/bash
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
if [ -z "$COMMIT_SOURCE" ]; then
STAGED_DIFF=$(git diff --cached)
if [ -n "$STAGED_DIFF" ]; then
echo "$STAGED_DIFF" | llm -t commit > "$COMMIT_MSG_FILE"
fi
fi
and configured: git config --global core.hooksPath ~/.config/git/hooks
I use llm tool with commit template set as:
llm ‘Write a concise Git commit message in the Conventional Commits format based on the following diff. Use the structure "(): ". Do not wrap the message in markdown code blocks. Output ONLY the message itself.’ --save commit
If I stage some changes and run in terminal:
git diff --cached | llm -t commit
chore: update project configuration and documentation
I get expected result, but nothing in Sublime Merge Commit Message box, where I expected autogenerated message.
Any ideas?