I'm using post-receive-email
hook from the Git distribution to send e-mails to certain users when Git repository is updated (hook invoked from post-receive
).
All my repositories were managed manually. Now, I get so many repos and so many users and groups that I have to upgrade to some Git repository management system. I picked Gitolite.
But I am a bit at loss on how to configure the e-mail notifications.
Update: I will elaborate the question a bit:
First question is: Where should I put the hook and should I change it somehow so it would work with Gitolite?
Second question:
The standard post-receive-email
hook depends on three parameters in *.git/config
: hooks.envelopesender
, hooks.emailprefix
and hooks.mailinglist
.
These parameters are, in general, different for each repository that I move under Gitolite. In practice, they are the same for the same permission groups — users, which have access to the repository, receive notifications, others — not.
I would like to avoid editing config
file for each repository manually. It would be much more fun if I could configure everything in the same, centralized, place for whole Gitolite.
So, any hints?
Here is a quick one liner to add descriptions to your gitolite.conf with the same name as the repo. You need this if you are using this big @almostall approach and gitolite so that you have descriptions for each repo. This saved me an hour of typing, so had to share:
Try first:
Then try with edit in place, but still make a backup prior:
Then do edit in place:
Cheers!
at the moment, this does not work:
I presume you would like it to work, but it's kinda low on my list right now due to other pressures, and the fact that there is a workaround:
Hope that helps, and sorry about the oversight on the @all
You can look at the doc hook for starters:
But the GitoliteV3 doc on 'mirroring' provides an alternative to a custom hook.
For the second question:
The doc gitolite.conf is quite clear:
The gitolite cookbook tells how to configure hooks:
1. Enable local non-core programs in gitolite
Edit the gitolite configuration file (usually
~git/.gitolite.rc
) and uncomment the following line:LOCAL_CODE => "$rc{GL_ADMIN_BASE}/local"
Ensure to read the security warnings.
2. Enable repository specific hooks
Uncommenting the
repo-specific-hooks
line in the gitolite configuration file.3. Add the email hook
Put the correspondig post-receive hook executable (I use git-multimail) in your gitolite-admin repository as the file
/local/hooks/repo-specific/git-multimail
.Commit and push it.
4. Configure settings for multimail hook
To allow adding config keys via the gitolite config file edit the gitolite config file
~git/.gitolite.rc
and update the following line:GIT_CONFIG_KEYS => ".*"
Ensure to read the security warning. You may want to narrow it down to
GIT_CONFIG_KEYS => "multimailhook\..*"
.5. Configure the multimail email hook
This is an example configuration of the
gitolite.conf
file in the gitolite-admin repository:I decided to use repo specific hooks and store them in the gitolite-admin repository. Alternatively, you could use global hooks (
/local/hooks/common
) or store them somewhere else on the gitolite server and pointLOCAL_CODE
there.