douo / magit-gptcommit

Magit commit with help of gpt
GNU General Public License v3.0
44 stars 4 forks source link

Feature Request: Allow gptcommit to respect `prepare-commit-msg` hook #5

Open rogsme opened 5 days ago

rogsme commented 5 days ago

Hey! First of all, thank you for this amazing plugin!

I have one issue with it though: How can it be configured to respect my prepare-commit-msg hook? My hook prepends the commit message with a ticket number, like this:

#!/bin/sh
TICKETNO=$(git rev-parse --abbrev-ref HEAD | grep -o -E '[A-Z]+-[0-9]+' | head -n1)

if [ -n "$TICKETNO" ]; then
    sed -i.bak -e "1s/^/$TICKETNO /" "$1"
fi

However, gptcommit overrides this behavior, and now I have to manually add the ticket number to the commit message. It's not a big deal, but it would be a nice improvement!

douo commented 6 hours ago

Thank you for your feedback. The magit-gptcommit-commit-accept function clears and saves the existing commit message from COMMIT_EDITMSG to log-edit-comment-ring. This behavior results in your prepare-commit-msg being cleared. You can then cycle through them using M-p and M-n. It is a bit challenging to distinguish whether the existing commit message in COMMIT_EDITMSG comes from prepare-commit-msg or if it's a message that was being edited.