gpt4 book ai didi

git - 如何使用 Gitolite 设置 post-receive-email Git hook

转载 作者:IT王子 更新时间:2023-10-29 01:30:07 24 4
gpt4 key购买 nike

我正在使用 Git 发行版中的 post-receive-email Hook 在 Git 存储库更新时向特定用户发送电子邮件(从 post-receive 调用 Hook >).

我所有的存储库都是手动管理的。现在,我得到了如此多的存储库以及如此多的用户和组,以至于我必须升级到某个 Git 存储库管理系统。我选择了 Gitolite。

但我对如何配置电子邮件通知有点不知所措。

更新:我会详细说明这个问题:

第一个问题是:我应该把钩子(Hook)放在哪里,我是否应该以某种方式改变它以便它可以与 Gitolite 一起工作?

第二个问题:

标准的post-receive-email钩子(Hook)依赖于*.git/config中的三个参数:hooks.envelopesender, hooks.emailprefixhooks.mailinglist

一般来说,这些参数对于我在 Gitolite 下移动的每个存储库都是不同的。实际上,对于相同的权限组,它们是相同的 - 有权访问存储库的用户会收到通知,而其他用户 - 则不会。

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

那么,有什么提示吗?

最佳答案

你可以看看doc hook对于初学者:

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.

但是GitoliteV3 doc on 'mirroring'提供自定义 Hook 的替代方案。


对于第二个问题:

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.

doc gitolite.conf很清楚:

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.

关于git - 如何使用 Gitolite 设置 post-receive-email Git hook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5055190/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com