特定储存库的gitolite钩子 [英] gitolite hook for specific repository

查看:87
本文介绍了特定储存库的gitolite钩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白如何为gitolite中的特定存储库创建接收后挂钩(非root用户安装)

我的裸存储库包含一个网站,该网站应将工作目录复制到docRoot (GIT_WORK_TREE=/path/htdocs git checkout -f)更新

在使用甘露醇之前,我只需要更新特定存储库的钩子即可.
Gitolite文档提到所有挂钩都应位于hooks/common,因此我不知道它是如何工作的.

钩子的名称应该是什么,应该位于何处以及应该如何更改其结构(如果应该)?

解决方案

2013年7月更新:以下内容适用于gitolite V2(或"g2"),这是OP当时(2011年11月)使用的版本.

2013年8月更新,使用最新的gitolite 3.x: 您现在具有官方特定的回购挂钩:

基本上,它只是在<repo.git>/hooks中创建一个指向$rc{LOCAL_CODE}/hooks/repo-specific中某些文件的符号链接(gitolite-admin回购除外)


gitolite/hooks/common中的所有钩子都复制到Gitolite管理的所有存储库中,如钩子中所述传播文档.
这意味着您的挂钩脚本必须根据执行所述挂钩的存储库采取特定的操作.

您可以使用$GL_REPO变量(由gitolite设置并为其收到的任何git命令传递给其所有脚本).

或者您可以使用在gitolite服务器上注册的某些git配置,例如镜像钩子所做的.参见 post-receive.mirrorpush.

OP Eyal R 添加了注释:

但是我仍然不知道它是如何完成的(我知道$GL_REPO用于确定我要更新的存储库,但是缺少实际部分).
我用echo "test"创建了一个名为post-receive.test的文件,将其放在$HOME/gitolite/hooks/common中,运行了gl-setup,从工作站运行了推-没有任何反应(没有"test"输出)

我回答:

该钩子应作为链接显示在gitolite服务器上回购的hook目录中,并链接回.gitolite/common/hook.请注意,它应该在$HOME/.gitolite/common/hook中,而不是在/gitolite中.

OP确认缺少点是问题所在.

在gitolite中的钩子传播中详细介绍了添加钩子的过程 "使用挂钩"中的用法.

I don't understand how do I create a post-receive hook for a specific repository in gitolite (non-root install)

My bare repository contains a website that should copy the working directory to the docRoot (GIT_WORK_TREE=/path/htdocs git checkout -f) on update

Before gitolite, I would just update the hook for the specific repository.
Gitolite documentation mentions that all hooks should be at hooks/common so I don't understand how it works.

What should be the name of hooks, where it should be located and how it's structure should be changed (if it should)?

解决方案

Update July 2013: what follows is for gitolite V2 (or 'g2'), which was the version used by the OP at the time (November 2011).

Update August 2013, with the latest gitolite 3.x: You now have official specific repo hook:

it's basically just creating a symlink in <repo.git>/hooks pointing to some file inside $rc{LOCAL_CODE}/hooks/repo-specific (except the gitolite-admin repo)


All hooks in gitolite/hooks/common are replicated in all repositories managed by Gitolite, as detailed in the hook propagation documentation.
That means your hook script must take specific action depending on the repo which execute said hook.

You can either use the $GL_REPO variable (which gitolite set and pass to all its scripts for any git command it receives).

Or you can use some git configuration registered on the gitolite server, like the mirroring hook does. See the post-receive.mirrorpush hook.

The OP Eyal R adds in the comments:

But I still don't understand how it is done (I understand that $GL_REPO is used to determine which repo I am updating but I'm missing the practical part).
I have created a file called post-receive.test with echo "test", put it in $HOME/gitolite/hooks/common, ran gl-setup, ran push from workstation - nothing happens (no "test" output)

To which I replied:

The hook should appear in the hook directory of your repo on the gitolite server as a link, linking back to the .gitolite/common/hook. Note that it should be in $HOME/.gitolite/common/hook, not /gitolite.

The OP confirms the missing dot was the issue.

The process to add an hook is detailed in Hook propagation in gitolite, and their usage in "Using Hooks".

这篇关于特定储存库的gitolite钩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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