特定存储库的 gitolite 挂钩
我不明白如何为 gitolite 中的特定存储库创建接收后挂钩(非 root 安装)
我的裸存储库包含一个网站,该网站应将工作目录复制到 docRoot (GIT_WORK_TREE=/path/htdocs git checkout -f
) on update
在 gitolite 之前,我只会更新特定存储库的挂钩。
Gitolite 文档提到所有钩子都应该位于 hooks/common ,所以我不明白它是如何工作的。
钩子的名称应该是什么,它应该位于哪里以及它的结构应该如何改变(如果应该的话)?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
2013 年 7 月更新:以下内容适用于 gitolite V2(或“g2”),这是 OP 当时(2011 年 11 月)使用的版本。
2013 年 8 月更新,使用最新的 gitolite 3.x:
您现在拥有官方特定存储库挂钩:
gitolite/hooks/common
中的所有钩子都会复制到 Gitolite 管理的所有存储库中,详细信息请参见 钩子传播文档。这意味着您的钩子脚本必须根据执行所述钩子的存储库采取特定操作。
您可以使用 $GL_REPO 变量(gitolite 设置该变量并将其传递给它接收的任何 git 命令的所有脚本)。
或者您可以使用在 gitolite 服务器上注册的一些 git 配置,例如 镜像挂钩。请参阅
post-receive.mirrorpush
钩子。OP Eyal R 在评论中添加:
我对此回复:
OP 确认缺少的点是问题所在。
添加钩子的过程在 gitolite 中的钩子传播中有详细介绍,其用法在“ 使用 Hooks”。
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:
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:
To which I replied:
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 的人来说,这是一个相当普遍的需求,并且当不是一个非常高级的用户时,似乎有点难以解决未解决的问题(至少对我来说是这样)。
来回跟踪 stackoverflow 和 gitolite 的链接可能会有点令人困惑。这些是我的结论以及我为实现这一目标所遵循的道路。
正如 @VonC 提到的,自 版本 3.5.3.1 (<一个href="https://github.com/sitaramc/gitolite/commit/62fb31755abb7ad93e17a6fe8880b74eb17086fa" rel="nofollow noreferrer">github 链接)
更新/升级 Gitolite
你应该做的第一件事正在更新您的 gitolite 存储库。因此,ssh 进入托管 gitolite 的服务器,并以 git 用户(通常
)身份移动到安装 gitolite 的位置(通常
)/home/git/gitolite
) git示例:
然后我们必须升级 gitolite。为此,首先我们需要更新 gitolite 存储库
然后我们必须重复 install 命令(确保使用与之前相同的参数)
最后再次运行安装程序。
如果这不起作用,您可能还没有在
PATH
中设置 gitolite 可执行文件,因此您可以执行以下操作:$ src/gitolite setup
Gitolite Settings (The "RC"文件)
这是最让我困惑的部分之一,但最终它非常简单。
著名的“rc”文件位于 git 的主目录
/home/git/.gitolite.rc
中。确保您有一个名为LOCAL_CODE
的变量,您应该在该文件上看到类似的内容,如果没有,请添加它。在“命令启用功能”部分中,您应该确保 repo-specific-hooks 可用,如果不可用,请添加它。
这是文档的链接
编写存储库特定的挂钩
最后,在您的 local
gitolite-admin
存储库中,在您刚刚在中设置的目录下创建以下目录hooks/repo-specific
LOCAL_CODE
变量,例如:之后,您实际上可以将钩子脚本添加到该位置,并通过 gitolite conf 文件管理它们,如 文档中所述。确保脚本可执行。
再次,我希望这对你们中的一些人有所帮助。
干杯!
This is a fairly common need for someone using gitolite, and appears to be a little difficult to tie up loose ends when being not a very advanced user (at leas it was for me).
Following stackoverflow's and gitolite's links back and forth can be a little confusing. These are my conclusions and the path I followed to be able to achieve this.
As @VonC mentioned creating repository specific hooks is already possible since version 3.5.3.1 (github link)
Update/Upgrade Gitolite
The first thing you should do is update your gitolite repo. So ssh into your server that is hosting gitolite and move to the location where gitolite is installed (usually
/home/git/gitolite
) as the git user (usuallygit
)Example:
Then we have to upgrade gitolite. To do so, first we need to update the gitolite repository
Then we have to repeat the install command (make sure you use the same arguments as before)
And finally run the setup again.
If that doesn't work, you probably haven't set up gitolite executable in your
PATH
, so you could do something like this:$ src/gitolite setup
Gitolite Settings (The "RC" file)
This was one of the parts that confused me the most, but it ended up it was pretty straight forward.
The famous "rc" file is located at git's home directory
/home/git/.gitolite.rc
. There make sure you have a variable calledLOCAL_CODE
, you should see something like this on that file, if not, add it.And in the "commands an feature to enable" section you should make sure that
repo-specific-hooks
is available, if not, add it.Here is the link to the documentation
Writing Repository Specific Hooks
Finally, in your local
gitolite-admin
repository create the following directorieshooks/repo-specific
under the directory you just set in theLOCAL_CODE
variable, for example:After that you can actually add your hooks scripts to that location and manage them through the gitolite conf file as stated in the documentation. Make sure the scripts are executable.
Again, I hope this helps some of you guys.
Cheers!