如何使用Gitolite设置post-receive-email Git钩子 [英] How to setup post-receive-email Git hook with Gitolite

查看:588
本文介绍了如何使用Gitolite设置post-receive-email Git钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Git发行版中的 post-receive-email 钩子在更新Git存储库时向某些用户发送电子邮件(挂钩从 post-receive )。



我所有的存储库都是手动管理的。现在,我得到了太多的回购和许多用户和团体,因此我必须升级到一些Git存储库管理系统。我选择了Gitolite。



但我在配置电子邮件通知方面有点不知所措。



更新:我会详细阐述这个问题:

第一个问题是:我应该把钩子放在哪里,我应该怎样改变它它会和Gitolite一起工作吗?

第二个问题:
$ b

标准 post-receive -email hook取决于 *。git / config 中的三个参数: hooks.envelopesender hooks.emailprefix hooks.mailinglist



对于我在Gitolite下移动的每个存储库,这些参数通常不同。在实践中,它们对于相同的权限组是相同的 - 有权访问存储库的用户会收到通知,其他人则不会。



我想避免编辑手动为每个存储库配置 config 文件。如果我可以将所有内容配置在整个Gitolite的相同,集中的地方,那将会更加有趣。

那么,有什么提示?

解决方案

你可以看看 doc hook for starters:


我在哪里(管理员)放置钩子?



通常,所有钩子都进入钩子/ common 目录。只有针对 admin 回购的特殊后期更新挂钩进入挂钩/ gitolite-admin


但是 GitoliteV3 关于'镜像'的文档提供了自定义挂钩的替代方法。




第二个问题:


我想避免手动编辑每个存储库的配置文件。

如果我可以在整个Gitolite的相同,集中的位置配置所有内容,那将更加有趣。


doc gitolite。 conf 很明显:

lockquote

repo特定的git配置命令

有时你想为你的某些仓库指定 git config 设置。

例如,你可能有一个自定义的post-receive钩子,发送推送邮件时,这个钩子需要知道发送邮件给谁,等等。


你可以设置 git config 值:

示例用法:如果您在 hooks / co




 需要每个回购特定的配置信息,您可以这样做:  repo gitolite 
config hooks.mailinglist = gitolite-commits@example.tld
config hooks.emailprefix =[gitolite]
config foo.bar =
config foo.baz =




语法很简单:




  config sectionname.keyname = [可选value_string] 




这可以实现简单的 git config section.key值(对于前面的3个示例)或 git config --unset-all section.key (对于最后一个示例)。

其他形式( - add value_regex 等)不受支持。



注意:除非 rc 文件具有正确的设置,否则这将不起作用;请参阅变量 $ GL_GITCONFIG_KEYS $ GIT_CONFIG_KEYS (现在位于 GitoliteV3或'g3' gitolite rc 文件了解详细信息和安全信息。



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 the admin repo goes into hooks/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 = gitolite-commits@example.tld
    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, the value_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 gitolite rc file for details and security information.

这篇关于如何使用Gitolite设置post-receive-email Git钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆