gpt4 book ai didi

gitolite_admin Hook 和镜像

转载 作者:行者123 更新时间:2023-12-02 09:11:28 25 4
gpt4 key购买 nike

我想知道是否有一种简单的方法可以使用 gitolite_admin 为某些存储库安装 Hook 。

假设我想使用gitolite_admin<为仓库更新后 Hook 很棒/strong> 存储库克隆到我的工作站...

#conf/gitolite_conf
repo awesome
RW+ = deployer

更新后的内容:

#!/bin/sh
echo "Post receive-hook => updating Redmine repository"
sudo -u deployer perl -we '`cd /home/deployer/repo/awesome.git && git fetch -q --all`'

最佳答案

您还可以查看“repo-specific environment variables

A special form of the option syntax can be used to set repo-specific environment variables that are visible to gitolite triggers and any git hooks you may install.

For example, let's say you installed a post-update hook that initiates a CI job. By default, of course, this hook will be active for all gitolite-managed repos. However, you only want it to run for some specific repos, say r1, r2, and r4.

To do that, first add this to the gitolite.conf:

repo r1 r2 r4
option ENV.CI = 1

This creates an environment variable called GL_OPTION_CI with the value 1, before any trigger or hook is invoked.

Note: option names must start with ENV., followed by a sequence of characters composed of alphas, numbers, and the underscore character.

Now the hook running the CI job can easily decide what to do:

# exit if $GL_OPTION_CI is not set
[ -z $GL_OPTION_CI ] && exit

... rest of CI job code as before ...

Of course you can also do the opposite; i.e. decide that the listed repos should not run the CI job but all other repos should:

repo @all
option ENV.CI = 1

repo r1 r2 r4
option ENV.CI = ""
<小时/>

该功能是最近才出现的(开始于 commit 999f9cd39 ,但在本例中,完成于 commit 63865a16 2013 年 6 月的 3.5.2)。
但即使您没有该版本,也有其他方法可以使用选项变量来执行此操作,如该部分的最后部分所述。

Before this feature was added, you could still do this, by using the gitolite git-config command inside the hook code to test for options and configs set for the repo, like:

if gitolite git-config -q reponame gitolite-options.option-name
then
...

并且您可以以相同的方式使用 git 配置变量。
或者您可以使用组成员资格 - 请参阅针对 function "in_group" 的评论详情见“Easy.pm ”。

# in_group()

# return true if $ENV{GL_USER} is set and is in the given group

# shell equivalent
# if gitolite list-memberships $GL_USER | grep -x $GROUPNAME >/dev/null; then ...

关于gitolite_admin Hook 和镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18430522/

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