Re: distributing commit-msg hook automatically after git clone

2,051 views
Skip to first unread message

Shawn Pearce

unread,
Apr 19, 2013, 12:52:10 AM4/19/13
to Tomáš Pelka, repo-discuss
On Thu, Apr 18, 2013 at 5:14 AM, Tomáš Pelka <tomp...@gmail.com> wrote:
> Hi so far I need to execute scp manually after git clone or right before I
> want to commit/review
>
> scp -P 29418 yourlogin@host:hooks/commit-msg .git/hooks/
>
> for gerrit to work properly. I'm looking for the way how to this step
> automatically.
>
> Do you guys solved such thing before? If so how?

For security reasons there isn't a way to do this. Git doesn't want to
install hooks that execute automatically. By having users download the
hook and install it themselves they have an opportunity to review the
implementation before they execute it.

Emmanuel Grumbach

unread,
Apr 19, 2013, 2:55:55 AM4/19/13
to Shawn Pearce, Tomáš Pelka, repo-discuss
> --

You can always copy it to /usr/share/git-core/templates/hooks/ in the
linux image you give to your users (requires root access). This way,
any newly cloned git tree will include the hook.
This can be done on windows too (and most probably on any OS git runs on).

david.o...@gmail.com

unread,
Apr 19, 2013, 4:46:54 AM4/19/13
to repo-d...@googlegroups.com


Am Donnerstag, 18. April 2013 14:14:33 UTC+2 schrieb Tomáš Pelka:
Hi so far I need to execute scp manually after git clone or right before I want to commit/review


Another approach is to put your (custom) commit-msg under git control, say .git-hooks/commit-msg
and have git wrapper, say `g` around `git` and teach your user base to use it.
The wrapper's `g pull` command creates symbolic link from .git/hooks/commit-msg to .git-hooks/commit-msg.
You can see it in action here [1].

In that scenario it would be even advantageous to disable the copying of vanilla commit-msg from Gerrit installation site.



David

Reply all
Reply to author
Forward
0 new messages