Git挂钩 - 从远程存储库传播? [英] Git hooks - propagating from remote repository?

查看:217
本文介绍了Git挂钩 - 从远程存储库传播?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在寻找将现有的SVN仓库转换为git,然后在允许推送前使用Reviewboard进行评论。我最近才开始使用git,而且远离专家,但是我想要做的是有一个pre-push hook,它运行post-review以将更改提交到ReviewBoard。我有一个可以做到这一点的挂钩工作,但它看起来像不会自动传播到存储库的克隆。阅读它听起来似乎没有做到这一点,以防止强制执行用户的可执行代码,但这是一个内部唯一的存储库,我们希望执行这个和其他一些策略。有没有办法强制git将钩子传播到远程克隆,或者我们需要指示我们的开发人员运行将这些钩子置于其本地回购站的东西?

I'm currently looking to convert an existing SVN repository to git, and then to use Reviewboard for reviews before allowing pushes. I've only recently started using git and am far from an expert on it, however what I would like to do is have a pre-push hook which runs "post-review" to submit the changes to ReviewBoard. I have a hook working that will do this, however it looks like this is not propagated automatically to clones of the repository. Reading around it sounds like this isn't done to prevent forcing executable code on a user, however this is an internal-only repository and we want to enforce this and a few other policies. Is there a way to force git to propagate the hooks to remote clones or do we need to instruct our developers to run something that places those hooks in their local repos?

谢谢
- Adam

Thanks - Adam

推荐答案

Git没有内置的支持在克隆之间传输钩子,可选或其他。它具有可以修改或添加到新存储库的默认模板,但这些模板是从本地文件系统(或网络文件系统,视情况而定)提取的。有可能你可以使用一个系统来复制它们,或者把钩子本身放入存储库,并要求开发人员正确配置它们的克隆。

Git has no built-in support for transferring hooks between clones, optional or otherwise. It has default templates that you can modify or add to for new repositories, but those are pulled from the local filesystem (or network filesystem, as the case may be). It's possible that you could instrument a system for copying them, or put the hooks themselves into the repository and ask that developers configure their clone correctly.

也可以在发生推送时但在更新ref之前,在中央裸仓库上运行所需的钩子。这可以通过预接收或更新挂钩完成。这是否可以接受取决于这个钩子的实际功能,这从你的帖子中是不清楚的。

It might also be possible to run the hook you want on the central bare repository, when the push happens but before the ref is updated. This could be done with a pre-receive or update hook. Whether this is acceptable depends on the actual functionality of this hook, which isn't clear from your post.

阅读 http://www.reviewboard.org/docs/manual/dev/faq/ 听起来好像你应该鼓励你的开发者使用主题分支。一旦更改获得批准,它们可以合并到发布分支中。你可以有一个更新钩子,它只允许特权用户的特定分支或任何其他标准。这也可以使用Gitolite完成,您可以在 http://progit.org/book /ch4-8.html

Reading http://www.reviewboard.org/docs/manual/dev/faq/ it sounds like maybe you should encourage your developers to use topic branches. Once changes are approved, they can be merged into release branches. You could have an update hook which only allows pushes to particular branches from privileged users, or any other criteria. This could also be done using Gitolite, which you can read about at http://progit.org/book/ch4-8.html

如果您不承诺使用Reviewboard,则可以考虑 http://code.google.com/p/gerrit/ ,它可以更好地与Git集成并明确支持此工作流程。

If you're not committed to Reviewboard, you might consider http://code.google.com/p/gerrit/ which is better integrated with Git and explicitly supports this workflow

这篇关于Git挂钩 - 从远程存储库传播?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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