Gerrit:为相同级别的多个Git分支配置引用 [英] Gerrit: configure references for multiple Git branches of same level

查看:155
本文介绍了Gerrit:为相同级别的多个Git分支配置引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个大型项目,有许多团队在不同的模块上工作,并且为了保持"master"始终工作,我们在每次冲刺结束时都将几个团队分支合并到主分支(如果一切正常).每个团队都有其功能分支,完成后会转到团队分支.

We have big project with many teams working on different modules and to keep 'master' always working we're using several team branches merged to the main branch in the end of every sprint if everything is OK. Every team have their feature branches that go to the team branch when they are finished.

现在,我尝试将我们的项目移至Gerrit,以防止意外将其直接推入"master",但面临一些问题.我经常使用Git,但以前从未使用过Gerrit,因此我对他的神奇的名称空间"感到困惑.我已经搜索了官方文档,但仍然有很多隐患.

Now I try to move our project to the Gerrit to prohibit accidental direct pushes into 'master', but face several problems. I used Git a lot, but never used Gerrit before, so I'm little confused with his "magic namespaces". I've searched official documentation but still have lot of dark spots in mind.

我想做的是允许每个开发人员有权创建新的引用并向refs/heads/*(功能和团队分支)推送(包括强制使用),但不能直接推送到refs/负责人/负责人所有提交给master的提交都应通过Gerrit审查和我们的CI工具构建周期,因此应推送到refs/for/master.

What I want to do is to allow every developer to have right of creating new references and pushing (including force) to the refs/heads/* (feature and team branches), but not be able to push directly into refs/heads/master. All commits to the master should pass the Gerrit review and our CI tool build cycle so should be pushed to the refs/for/master.

我发现我不能同时允许引用"refs/heads/*"和拒绝引用"refs/heads/master".由于它们的路径是冲突的,因此一次只能工作一个(更通用).因此,我不能否认这样推向主人".

I found that I can't have both allowing reference for 'refs/heads/*' and denying for 'refs/heads/master'. Since their paths are clashed, only one of them works at a time (more generic one). So I can't deny pushes to the 'master' this way.

这是我的project.config的一部分:

Here is part of my project.config:

[access "refs/for/master"]
    push = group Developers
[access "refs/heads/*"]
    push = group Developers
[access "refs/heads/master"]
    push = deny group Developers

有人有为类似分支模型设置Gerrit的经验吗?如果您有解决此问题或配置收据的想法,请在此处发布.

Does anybody have experience of setting Gerrit for similar branching model? If you have any idea how to solve this problem or configuration receipt, post it here, please.

推荐答案

为Gerrit项目设置引用时,可能会引起混淆.实际上,"refs/heads/*"允许将用户推入所有已添加用户组的分支中,因此上述配置仅适用于所描述的目标.

It may be little confusing when you set references for Gerrit project. In fact "refs/heads/*" allows pushes into branches for all added groups of users, so the configuration from the above just will not work for described goal.

这是我实际上解决问题的方式:

This is how I actually solved issue:

[access "refs/for/master"]
    push = group Developers
[access "^refs/heads/OR-.*"]
    create = group Developers
    push = group Developers
    pushMerge = group Developers
[access "refs/heads/master"]
    push = deny group Developers

由于我发现"refs/heads/*"的访问规则会覆盖此命名空间的所有拒绝规则,因此我将regexp用于以"OR-"前缀开头的功能分支,同时拒绝将其压入"master""分支.由于我们有几个团队的分支机构名为master,因此也很容易为其添加拒绝访问规则.只需使用"^ refs/heads/master-.*"正则表达式并拒绝所有推送即可.

Since I found that access rule for "refs/heads/*" overrides any denying rule for this namespace, I used regexp for our feature branches that starts with "OR-" prefix and at the same time denied pushes into "master" branch. Since we have several teams with their branches named master- it's easy to add denying access rule for them too. Just use "^refs/heads/master-.*" regexp and deny all pushes.

但这仅在您的分支可以通过regexp合并时起作用.

But this only works when your branches can be united via regexp.

这篇关于Gerrit:为相同级别的多个Git分支配置引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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