Gerrit 3.7-Submit Rules How to apply multiple branches.

240 views
Skip to first unread message

Yingchun Li

unread,
Jul 31, 2023, 9:05:07 AM7/31/23
to Repo and Gerrit Discussion
Hi, Teams
      I want to add Label Verified as a submit requirement with multiple branches, 
say master and Branch_B. so I wrote some rules:
      In the parent project:
 [label "Verified"]
    branch = refs/heads/master
    function = NoBlock
    value = -1 Fails
    value = 0 No score
    value = +1 Verified
    copyCondition = changekind:NO_CHANGE OR changekind:NO_CODE_CHANGE
    defaultValue = 0
[submit-requirement "Verified"]
    submittableIf = label:Verified=MAX AND -label:Verified=MIN
    applicableIf = branch:refs/heads/master
    canOverrideInChildProjects = true
    
    In the child project:
[label "Verified"]
    branch = refs/heads/master
    branch = refs/heads/ibrt_rc_0.6
    function = NoBlock
    value = -1 Fails
    value = 0 No score
    value = +1 Verified
    copyCondition = changekind:NO_CHANGE OR changekind:NO_CODE_CHANGE
    defaultValue = 0

[submit-requirement "Verified"]
    submittableIf = label:Verified=MAX AND -label:Verified=MIN
    applicableIf = branch:^refs/heads/(master|Branch_B)

This can not work, there is no label Verified with change of Branch_B(child project).
seems the regulator is no workable.
(I have also tried applicableIf = branch:^refs/heads/(master|Branch_B).*, still not work)
But if a change the 'applicableIf' like this

 applicableIf = branch:refs/heads/master OR branch:refs/heads/Branch_B
The label Verified display.

But this maybe not good, e.g. if I have a lot of branches, I have to spell
 a lot of characters.
So are there better methods? please give some advice, thanks!

Br,
Yingchun

Martin Fick

unread,
Jul 31, 2023, 6:17:18 PM7/31/23
to Yingchun Li, Repo and Gerrit Discussion
I am not sure if it would work well, but you might be able to define your project/branch combinations using a named destination https://gerrit-review.googlesource.com/Documentation/user-named-destinations.html and then you might be able to reference that named destination via the destination:'[name=]NAME[,user=USER|,group=GROUP]' search operator in your applicableIf rule.

On the current Gerrit master branch (unreleased), it is now possible to upload changes for review to a group's ref in the All-Users repo if they contain changes to the group's destinations (or query) definitions, this makes it easier to maintain these files. We are also currently working on adding a WUI to edit them more easily,

-Martin

Yingchun Li

unread,
Jul 31, 2023, 10:59:42 PM7/31/23
to Repo and Gerrit Discussion
That seems more complicated than regulator or my not good method.
 
On the current Gerrit master branch (unreleased), it is now possible to upload changes for review to a group's ref in the All-Users repo if they contain changes to the group's destinations (or query) definitions, this makes it easier to maintain these files. We are also currently working on adding a WUI to edit them more easily,
This is more convenient,waiting for the WUI features, thanks for your hard work.  
 
-Martin
Reply all
Reply to author
Forward
0 new messages