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?
You can look at the doc hook for starters:
where do I (the admin) put the hooks?
In general, all hooks go into the
hooks/common
directory. Only the special post-update hook meant for theadmin
repo goes intohooks/gitolite-admin
.
But the GitoliteV3 doc on 'mirroring' provides an alternative to a custom hook.
For the second question:
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.
The doc gitolite.conf is quite clear:
repo specific git config commands
Sometimes you want to specify
git config
settings for some of your repos.
For example, you may have a custom post-receive hook that sends an email when a push happens, and this hook needs to know whom to send the email to, etc.You can set
git config
values by specifying something like this within a "repo" paragraph:example usage: if you placed a hook in
hooks/common
that requires configuration information that is specific to each repo, you could do this:
repo gitolite
config hooks.mailinglist = [email protected]
config hooks.emailprefix = "[gitolite] "
config foo.bar = ""
config foo.baz =
The syntax is simple:
config sectionname.keyname = [optional value_string]
This does either a plain "
git config section.key value
" (for the first 3 examples above) or "git config --unset-all section.key
" (for the last example).
Other forms (--add
, thevalue_regex
, etc) are not supported.Note: this won't work unless the
rc
file has the right settings; please see comments around the variable$GL_GITCONFIG_KEYS
$GIT_CONFIG_KEYS
(now in GitoliteV3 or 'g3') in gitoliterc
file for details and security information.