prepare-commit-msg hook

182 views
Skip to first unread message

Lev Zlotin

unread,
Dec 13, 2016, 2:50:45 PM12/13/16
to git-cola
is there any possibility to use the prepare-commit-msg hook to create the necessary comment? for example, I use git comment like:
        "Branch:\n\tlocal:$current_branch\n\tremote:$remote_branch\n\thash:$hash\n" .
        "Commit Message: <add text here>\n" .
        "API Test: <Result>\n" .
        "Peer Review: <name>\n" .
        "Additional Message: \n\t<Tests>\n\t<Docs>\n\n\n" ;
I can create it in "start_commit" hook or prepare-commit-msg; I want to add info automatically( branch name, hash, etc. )


David Aguilar

unread,
Dec 13, 2016, 7:10:16 PM12/13/16
to Lev Zlotin, git-cola
We can add a feature that lets you invokes the prepare-commit-msg.
Open an issue on Github.
--
David

David Aguilar

unread,
Dec 13, 2016, 8:24:07 PM12/13/16
to Lev Zlotin, git-cola

I may have beat you to it.  It's available in the "Commit" menu.

I used a separate hook because I noticed that having a regular Git hook
installed was already causing it to run when preparing commits via cola,
and it's useful to have a cola-specific one, so I made it use the
cola-prepare-commit-msg hook instead of Git's hook.

It's best to keep these separate.

If you'd like to use a hook at a different path, or maybe use
the same hook for all repositories, you can specify the path to the
hook by setting the cola.prepareCommitMessageHook git config variable.
--
David

Lev Zlotin

unread,
Dec 14, 2016, 5:44:50 AM12/14/16
to git-cola
Where can I find the "Commit -> Prepare Commit Message"? There is no such item in menu.

David Aguilar

unread,
Dec 14, 2016, 3:08:28 PM12/14/16
to Lev Zlotin, git-cola
On Wed, Dec 14, 2016 at 2:44 AM, Lev Zlotin <lev.z...@gmail.com> wrote:
Where can I find the "Commit -> Prepare Commit Message"? There is no such item in menu.

It's currently only in the development version that you get if you
clone the project from github and run from the source tree.

example:

  ./git-cola/bin/git-cola

It'll be included in the next release otherwise.
--
David

Lev Zlotin

unread,
Feb 1, 2017, 3:32:44 AM2/1/17
to git-cola
Hi,
Just tried to use
".git/GIT_COLA_MSG" file name is not passed in a first parameter, parameter is empty; When using it hardcoded, hook is working OK.



On Tuesday, December 13, 2016 at 9:50:45 PM UTC+2, Lev Zlotin wrote:

David Aguilar

unread,
Feb 1, 2017, 4:29:56 AM2/1/17
to Lev Zlotin, git-cola
On Wed, Feb 1, 2017 at 12:32 AM, Lev Zlotin <lev.z...@gmail.com> wrote:
> Hi,
> Just tried to use
> ".git/GIT_COLA_MSG" file name is not passed in a first parameter, parameter
> is empty; When using it hardcoded, hook is working OK.

We support a cola-specific hook. See the documentation.
It must be named "cola-prepare-commit-msg"
instead of "prepare-commit-msg".

The cola hook is invoked via the Commit->Prepare Commit Message
menu action. It is not invoked by Git when preparing commits.

The cola hook is passed the absolute path to the file
as its first argument. Example:


#!/bin/sh
# .git/hooks/cola-prepare-commit-msg

echo subject: ok >"$1"
echo >>"$1"
echo extended description: "$1">>"$1"
exit 0
--
David

Lev Zlotin

unread,
Jul 12, 2017, 1:55:19 AM7/12/17
to git-cola, lev.z...@gmail.com
Hi, I found strange behavior when there is cola-prepare-commit-message and commit --amend is used in cola
also the hook checks and does not add a message if message is not empty, it is added anyway.
It does not caused when using commit --amend from command line;
Reply all
Reply to author
Forward
0 new messages