Overriding the built in Verified submit requirement

441 views
Skip to first unread message

euph...@gmail.com

unread,
Dec 21, 2022, 9:25:22 PM12/21/22
to Repo and Gerrit Discussion
We're on Gerrit 3.6.1.  Some of our repos use the Verified label, but many do not, so it has been very common for me to add this prolog submit rule when setting up a new repository where its users don't want to use the Verified label:

submit_rule(submit(CR, V)) :-
    gerrit:max_with_block(-2, 2, 'Code-Review', CR),
    V = label('Verified', may(_)).

I'm converting from prolog submit rules to submit requirements.  Since the number of repos that don't use the Verified label outnumber the ones that do use it, I tried deleting that prolog rule from a repo that doesn't use the Verified label, removing the deprecated function lines from the definition of the Verified label in All-Projects, and simply not including the Verified label in any submit-requirement sections in either All-Projects, or the project's repo.  I did define a submit-requirement in All_projects for Code-Review, which looks like this:

[submit-requirement "Code-Review"]
        description = A +2 vote from a non-uploader is required for the Code-Review label. A -2 vote is blocking.
        submittableIf = label:Code-Review=MAX,user=non_uploader AND -label:Code-Review=MIN
        canOverrideInChildProjects = true

When I look at a review for this repo, I see in the Submit Requirements section of the UI that I have two entries: Code-Review (with description text and condition matching my submit-requirement from All-Projects), and, to my surprise, Verified with the condition "label:Verified=MAX -label:Verified=MIN".  Where did that default submit requirement come from and how do I remove it?  I've tried setting something like this in All-Projects:

[submit-requirement "Verified"]
        submittableIf = is:true
        canOverrideInChildProjects = true

but instead of this submit-requirement replacing the built in one, I then end up with *two* Verified submit requirements in reviews on this repo, one with my new is:true condition, and the other with the built in condition, and the review is not submittable until *both* are satisfied.

So how do I override the built in Verified and Code-Review conditions in repos where I don't want to use those labels at all?  In prolog, I could do that with a may rule.  What's the equivalent with a submit requirement, and is it possible to make that the global default for Verified?


thanks,
--Andrew

euph...@gmail.com

unread,
Dec 21, 2022, 9:54:55 PM12/21/22
to Repo and Gerrit Discussion
To answer my own question, it appears that I can get the behavior I was expecting by adding function settings back into my label definitions in All-Projects, setting them to NoBlock:

[label "Verified"]
        value = -1 Fails
        value = 0 No score
        value = +1 Verified
        defaultValue = 0
        function = NoBlock

It looks like even though the label.label-name.function setting is deprecated and there was a submit-requirement of the same name, leaving function unset in a label caused it to create a duplicate rule with the default MaxWithBlock function.


--Andrew

Yingchun Li

unread,
Aug 4, 2023, 3:54:33 AM8/4/23
to Repo and Gerrit Discussion
On Thursday, December 22, 2022 at 10:54:55 AM UTC+8 euph...@gmail.com wrote:
To answer my own question, it appears that I can get the behavior I was expecting by adding function settings back into my label definitions in All-Projects, setting them to NoBlock:

[label "Verified"]
        value = -1 Fails
        value = 0 No score
        value = +1 Verified
        defaultValue = 0
        function = NoBlock

It looks like even though the label.label-name.function setting is deprecated and there was a submit-requirement of the same name, leaving function unset in a label caused it to create a duplicate rule with the default MaxWithBlock function.

Hi, I want to do almost same thing as this,  and more, want to remove the label Verified in the child project completely.
Now according to this submit requirement, the child  project still show the label-Verified, just its value is true.

Yingchun Li

unread,
Aug 5, 2023, 3:54:19 AM8/5/23
to Repo and Gerrit Discussion
On Friday, August 4, 2023 at 3:54:33 PM UTC+8 Yingchun Li wrote:
On Thursday, December 22, 2022 at 10:54:55 AM UTC+8 euph...@gmail.com wrote:
To answer my own question, it appears that I can get the behavior I was expecting by adding function settings back into my label definitions in All-Projects, setting them to NoBlock:

[label "Verified"]
        value = -1 Fails
        value = 0 No score
        value = +1 Verified
        defaultValue = 0
        function = NoBlock

It looks like even though the label.label-name.function setting is deprecated and there was a submit-requirement of the same name, leaving function unset in a label caused it to create a duplicate rule with the default MaxWithBlock function.

Hi, I want to do almost same thing as this,  and more, want to remove the label Verified in the child project completely.
Now according to this submit requirement, the child  project still show the label-Verified, just its value is true.
just answer myself's question, removing all the branches in the submit requirement  get the expected result:

[submit-requirement "Verified"]
    submittableIf = is:true
    applicableIf = -branch:^refs/heads/.*
Reply all
Reply to author
Forward
0 new messages