Re: OWNERS files plugin

276 views
Skip to first unread message

Saša Živkov

unread,
Apr 24, 2013, 7:30:55 AM4/24/13
to Vadim Spivak, repo-d...@googlegroups.com



On Wed, Apr 24, 2013 at 5:37 AM, Vadim Spivak <vadim....@gmail.com> wrote:
I just released a plugin https://github.com/vadims/gerrit-owners thats tries to enable path based submit rules.

The rules are defined in OWNERS files in the repo itself. This is inspired by http://www.chromium.org/developers/owners-files.

Has anyone attempted this before? Is there a better way of getting something similar to this? Feedback greatly appreciated. 

Looking at your sample rules.pl:

submit_rule(S) :-
  gerrit:default_submit(D),
  D =.. [submit | Ds],
  gerrit:get_commit_labels(L),
  gerrit_owners:add_owner_approval(L, Ds, A),
  S =.. [submit | A]. 

it could be made more explicit that the add_owner_approval will only search
for users who voted Code-Review+2:

submit_rule(S) :-
  gerrit:default_submit(D),
  D =.. [submit | Ds],
  findall(U, gerrit:commit_label(label('Code-Review', 2), U), Approvers),
  gerrit_owners:add_owner_approval(Approvers, Ds, A),
  S =.. [submit | A].


Another way to write the rules.pl would be without reusing the gerrit:default_submit:

submit_rule(submit(CR, V)) :-
  base(CR, V),
  findall(U, gerrit:commit_label(label('Code-Review', 2), U), Approvers),
  gerrit_owners:is_owner_approved(Approvers).

submit_rule(submit(CR, V, OA) :-
  base(CR, V),
  OA = label('Owner-Approval', need(_)).

base(CR, V) :-
  gerrit:max_with_block(-2, 2, 'Code-Review', CR),
  gerrit:max_with_block(-1, 1, 'Verified', V).


Further, this plugin would probably be much more useful if it exposes
ownerships for each file from the current change as prolog facts:

gerrit_owners:owner(user(100000), 'a/b/c').
gerrit_owners:owner(user(100001), 'a/b/c').
gerrit_owners:owner(user(100001), 'x/y/z'). 
...

and leaves it to the rules.pl to make use of such facts. Then, instead
of the one fixed logic in the add_owner_approval, we are free
to make use of the ownership information in any way we imagine.
For example, writing a rule where at least two owners have to approve
the change would then be possible.
The plugin may still expose the add_owner_approval as a convenience.

Saša



Thanks,
Vadim

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Vadim Spivak

unread,
Apr 27, 2013, 3:02:01 AM4/27/13
to Saša Živkov, repo-d...@googlegroups.com
I just updated the plugin based on your feedback.


Thanks,
Vadim
--
Vadim Spivak
va...@spivak.net

Vadim Spivak

unread,
Apr 29, 2013, 4:41:05 AM4/29/13
to repo-d...@googlegroups.com
I just added a second plugin (https://github.com/vadims/gerrit-owners) to automatically assign the OWNERS as reviewers. 

The current approach to use PostReviewers seems hacky, is there a better idea? I didn't want to reimplement the hook/email notification logic.

Also, are there any guarantees/limitations on plugins depending on other plugins? I could extract the common class into its own library, but from my testing it seemed to work fine without it.

Thanks,
Vadim
--
Vadim Spivak
va...@spivak.net

Muaaz Saleem

unread,
Nov 11, 2015, 5:02:30 PM11/11/15
to Repo and Gerrit Discussion
Hi Vadim,

Thanks for the plugin. Is there a way to access the OWNERS info through the gerrit query api?

Muaaz Saleem

unread,
Nov 11, 2015, 5:06:20 PM11/11/15
to Repo and Gerrit Discussion, vadim....@gmail.com
Hi Vadim,

Is there a way to access the OWNERS information from the "gerrit query" interface? 
Reply all
Reply to author
Forward
0 new messages