hook - 特定存储库的 gitolite 钩子(Hook)

标签 hook gitolite

我不明白如何为 创建接收后 Hook 具体 gitolite 中的存储库(非 root 安装)

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

在 gitolite 之前,我只会更新特定存储库的钩子(Hook)。
Gitolite 文档提到所有钩子(Hook)都应该在 hooks/common所以我不明白它是如何工作的。

钩子(Hook)的名称应该是什么,它应该放在哪里以及它的结构应该如何改变(如果应该的话)?

最佳答案

2013 年 7 月更新:以下是 gitolite V2(或“g2”),它是当时 OP 使用的版本(2011 年 11 月)。

2013 年 8 月更新,使用最新的 gitolite 3.x:
您现在拥有 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)


gitolite/hooks/common 中的所有 Hook 在 Gitolite 管理的所有存储库中复制,详见 hook propagation documentation .
这意味着你的钩子(Hook)脚本必须根据执行所述钩子(Hook)的仓库采取特定的行动。

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

或者您可以使用在 gitolite 服务器上注册的一些 git 配置,例如 mirroring hook does .见 post-receive.mirrorpush hook .

OP Eyal R在评论中添加:

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)



我回答说:

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.



OP 确认丢失的点是问题所在。

Hook propagation in gitolite 中详细介绍了添加钩子(Hook)的过程,以及它们在“Using Hooks”中的用法。

关于hook - 特定存储库的 gitolite 钩子(Hook),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8322860/

相关文章:

delphi - 低级键盘 Hook 问题: Keyboard state losed when application is not focused (Delphi)

c - Linux X11 C 想知道屏幕上任何地方的指针运动

gitolite:新存储库的默认 Remote

git - 被 gitolite 锁定并且无法 gl-admin-push

当我推送到 Git 存储库时,Gitolite 开始给我错误,错误大约为 "declined hooks"

Git:用 'post-receive'命令发送参数到 'git push' hook

git - 跳过提交消息上的多个 Hook ?

Gitolite 对分支的权限

c++ - 无法在 DLL 中创建 D3D11 SwapChain

git - 为什么我不能将新标签推送到服务器