submit rules combining Owners based on matchers and Owners details on a per-file basis

336 views
Skip to first unread message

Sweta Asnodkar

unread,
Aug 7, 2023, 6:04:41 AM8/7/23
to Repo and Gerrit Discussion
Hello Team,

I am sorry if I am creating a spam by creating another conversation, but I wanted to have a separate conversation/topic on my company's requirement for submit rules.
I am using below rules.pl and OWNERS file in order to get the approval from required reviewers on file/folder basis. Using examples give in this link for OWNERS plugin.

Below rules.pl and OWNERS file does satisfy my requirement of having a compulsory code review by an OWNER of that file.

submit_rule(S) :-
    gerrit:default_submit(X),
    X =.. [submit | Ls],
    add_non_author_approval(Ls, R1),
    gerrit_owners:add_match_owner_approval(R1, R),
    S =.. [submit | R].

submit_rule(submit(W)) :-
  gerrit_owners:findall_match_file_user(W).

OWNERS file
inherited: false
owners:
 - av
 - nk
matchers:
 - partial_regex: modules/
   owners:
    - rb
 - partial_regex: testing/
   owners:
    - group/test4

Problem:
In the OWNERS file, I am using groups to define ownership of a folder. We are planning to have set of OWNERS for a folder. It is expected that Author/committer may be a part of the group. While using "findall_match_file_user" the Author/committer becomes the OWNER of the file, and when he/she reviews the code submit button is enabled. 

I need variation in "findall_match_file_user" of OWNERS plugin such that even if the author is part of the group his/her review should not be considered.

I hope I have been able to put forward my requirements.

Thank you,
Sweta


Luca Milanesio

unread,
Aug 7, 2023, 9:27:54 AM8/7/23
to Repo and Gerrit Discussion, Luca Milanesio, Sweta Asnodkar
Hi Sweta,

On 7 Aug 2023, at 13:04, Sweta Asnodkar <sweta.notim...@gmail.com> wrote:

Hello Team,

I am sorry if I am creating a spam by creating another conversation, but I wanted to have a separate conversation/topic on my company's requirement for submit rules.

You can create new features requirements at [1].

I am using below rules.pl and OWNERS file in order to get the approval from required reviewers on file/folder basis.
Are you aware that Gerrit is abandoning Prolog rules? You can use the owners or code-owners plugins without the need of using Prolog: just use the submit requirements [2].
You mean that the author should be automatically excluded from the owners?
Why don’t you simply define a submit requirement that says that authors cannot self-approve changes?

Can you express your requirement without the use of Prolog?

[1] https://issues.gerritcodereview.com





--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/f3fb5a93-ba11-4897-bdb7-dfc5ae7aeb48n%40googlegroups.com.

Message has been deleted

Sweta Asnodkar

unread,
Aug 7, 2023, 2:16:58 PM8/7/23
to Repo and Gerrit Discussion
On Monday, August 7, 2023 at 6:57:54 PM UTC+5:30 Luca Milanesio wrote:
Hi Sweta,

On 7 Aug 2023, at 13:04, Sweta Asnodkar <sweta.notim...@gmail.com> wrote:

Hello Team,

I am sorry if I am creating a spam by creating another conversation, but I wanted to have a separate conversation/topic on my company's requirement for submit rules.

You can create new features requirements at [1].

I am using below rules.pl and OWNERS file in order to get the approval from required reviewers on file/folder basis.
Are you aware that Gerrit is abandoning Prolog rules? You can use the owners or code-owners plugins without the need of using Prolog: just use the submit requirements [2].

      I enabled submit requirement by adding "[owners] enableSubmitRequirement = true" under gerrit.config file.
      As per the document, there was no need to add submit requirement in project.config file. When I try to make submission, OWNERS are getting assigned but the  submit button is enabled by default. It was not checking for any conditions.

    Then added submit requirement as below:
    [submit-requirement "Code-Review"]
description = A maximum vote from a non-uploader is required for the \
              'Code-Review' label. A minimum vote is blocking.
submittableIf = label:Code-Review=MAX,user=non_uploader AND -label:Code-Review=MIN
canOverrideInChildProjects = true

    Now it needed code review which was expected. But when any user who is not a part of the OWNERS list gives a +2, the submission can be submitted as submit button is enabled.
    There is no condition for OWNERS votes requirement here.

   I thought just by enabling submit requirement all the conditions mentioned in the config document of OWNERS plugin would satisfy my requirments. But that's not the case.
   I think I am missing some configuration somehow. As at least default submit rule of getting code-review as +2 should have been available without submit requirements right?
>> Either exclude the author from OWNERS list of disable code review for author. 
Why don’t you simply define a submit requirement that says that authors cannot self-approve changes?

>> I tried using submittableIf = label:Code-Review=MAX,user=non_uploader AND -label:Code-Review=MIN  but as I mentioned above, any user can give a +2 not only the OWNERS . 

Can you express your requirement without the use of Prolog?
>> Do we have any specific examples, which can be referred to for implementing submit requirements? I am not able to find how to incorporate changes from OWNERS plugin into submit requirements.

Sweta Asnodkar

unread,
Aug 8, 2023, 8:41:29 AM8/8/23
to Repo and Gerrit Discussion
On Monday, August 7, 2023 at 11:46:58 PM UTC+5:30 Sweta Asnodkar wrote:
On Monday, August 7, 2023 at 6:57:54 PM UTC+5:30 Luca Milanesio wrote:
Hi Sweta,

On 7 Aug 2023, at 13:04, Sweta Asnodkar <sweta.notim...@gmail.com> wrote:

Hello Team,

I am sorry if I am creating a spam by creating another conversation, but I wanted to have a separate conversation/topic on my company's requirement for submit rules.

You can create new features requirements at [1].

I am using below rules.pl and OWNERS file in order to get the approval from required reviewers on file/folder basis.
Are you aware that Gerrit is abandoning Prolog rules? You can use the owners or code-owners plugins without the need of using Prolog: just use the submit requirements [2].

      I enabled submit requirement by adding "[owners] enableSubmitRequirement = true" under gerrit.config file.
      As per the document, there was no need to add submit requirement in project.config file. When I try to make submission, OWNERS are getting assigned but the  submit button is enabled by default. It was not checking for any conditions.

    Then added submit requirement as below:
    [submit-requirement "Code-Review"]
description = A maximum vote from a non-uploader is required for the \
              'Code-Review' label. A minimum vote is blocking.
submittableIf = label:Code-Review=MAX,user=non_uploader AND -label:Code-Review=MIN
canOverrideInChildProjects = true

    Now it needed code review which was expected. But when any user who is not a part of the OWNERS list gives a +2, the submission can be submitted as submit button is enabled.
    There is no condition for OWNERS votes requirement here.

   I thought just by enabling submit requirement all the conditions mentioned in the config document of OWNERS plugin would satisfy my requirments. But that's not the case.
   I think I am missing some configuration somehow. As at least default submit rule of getting code-review as +2 should have been available without submit requirements right?

>> Sorry for spam again. I was adding [owners] enableSubmitRequirement = true under gerrit.config file isntead of owners.config file hence it was not working. When I added it to owners.config file, submit requirememnts did work. 
>>  Now my only problem is using groups as OWNERS where author is part of the group.

Thanks,
Sweta
Reply all
Reply to author
Forward
0 new messages