Gerrit: configure references for multiple Git branches of same level

不问归期 提交于 2021-01-29 04:43:35

问题


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.

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.

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.

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.

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

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.


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/36922330/gerrit-configure-references-for-multiple-git-branches-of-same-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!