feat(commit-with-llm): include git log context in LLM prompt for consistent commit messages

This commit is contained in:
Janik von Rotz committed 2025-09-04 10:55:50 +02:00
1 parent 17ef23682b
commit 8c0231b293
1 file changed
+7 -3
+7 -3
View File
@@ -6,9 +6,13 @@ function commit-with-llm() {
PROMPT_FILE="tmp/llm_update"
echo -e "\nWrite prompt to $PROMPT_FILE."
cat << EOF > "$PROMPT_FILE"
Look at the git diff below and reply with a git commit message. Ensure that the commit message matches the conventional commits specification.
If possible add a scope. Reply with the commit message only.
Look at the git log and the git diff below and reply with a git commit message matching the changes and style of the log.
The commit message must comply with the conventional commits specification. Reply with the commit message only.
<<< git log -n 5 --pretty=format:"%ci: %B" >>>
$(git log -n 5 --pretty=format:"%ci: %B")
<<< git diff --staged >>>
$(git diff --staged)
EOF
@@ -40,4 +44,4 @@ EOF
if [[ "$CONFIRM" =~ ^[Ee]$ ]]; then
git commit --amend
fi
}
}