Re: [PATCH] git-commit: add a prepare-commit-msg hook

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




In the message hook, just grep if the template was already added. If it was, just return. If it was not, add it.

Ah, so you want me to always type ":q!" to exit and unnecessarily complicate the commit-msg hook. Cunning, but no, thanks.

I'll make an example.  This is my prepare-commit-msg hook:

diff_collect_changelog ()
{
  git diff "$@" -- \
   `git diff "$@" --name-status -r | \
        awk '/ChangeLog/ { print substr ($0, 3) }'` | sed -n \
    -e '/^@@/,/^+/ {' \
    -e '  s/^ //p' \
    -e '  t' \
    -e '}' \
    -e '/^diff/,/^@@/ {' \
    -e '  s/^diff --git a\/\(.*\)\/ChangeLog[^ ]* b\/.*/\1:/p' \
    -e '  tdummy' \
    -e '  :dummy' \
    -e '  d' \
    -e '}' \
    -e 's/^+//p' \
    -e 't'
}

diff_collect_changelog --cached > /tmp/foo$$
cat "$GIT_COMMIT_MSG" >> /tmp/foo$$ && \
  mv /tmp/foo$$ "$GIT_COMMIT_MSG"
rm -f /tmp/foo$$

or something like that. The alternative I see would be to start the vi editing session with "!!make_changelog --cached". So I thought about having an hook that runs the command for me. Do you have better ideas?

Paolo
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux