2012-07-19 39 views
14

我想要禁止更改的作者在中查看他/她自己的更改。我知道this suggested hack,但这并不能真正解决问题。从gerrit审查中排除作者

现在我learned from the gerrit issues gerrit的硬编码规则可以修改custom prolog code,所以它应该有可能修改工作流程,如我所愿。不过,我从来没有修改过gerrit的工作流程,而且我也不知道更多

有没有人有一个小工作使用这个prolog引擎gerrit的自定义规则的例子?

由于他们不需要我的团队改变当前的工作流程,我会高兴地接受其他方法来禁止作者进行自我评审。

回答

2

我发现这个谷歌组中一个非常简单的答案,更换2个gerrit:change_owner(O)谓词:groups.google.com/disable-self-review

在父项目(默认是全项目的项目)将此添加到项目中。在裁判/元/ config分支的配置文件:

[access "refs/*"] 
label-Code-Review = block -2..+2 group Change Owner 

,并在组文件在同一个分支中加入这一行

global:Change-Owner Change Owner 

然后采取允许直接进入子项目的项目的声明。配置:

label-Code-Review = -2..+2 group Developers 

确认执行写入父项目块语句,并给在儿童权利项目。如果允许和阻止在同一个文件中,则允许将取代(请参阅this)。 这将阻止变更的所有者给-2或+2。它会使-1和+1选项保持不变。您可以为可能使用的任何其他自定义标签添加类似的声明。

3

我不确定这是你在找什么,但它可能会给你一些启发。根据this discussion,仅当审阅者和更改所有者不是同一个人时,以下片段才会批准更改。

% If a reviewer approved the change, its OK. 
    submit_rule(submit(CR)) :- 
    change_owner(Owner), 
    max_with_block('Code-Review', -2, 2, ok(Reviewer)), 
    not_same(Owner, Reviewer), 
    CR = label('Code-Review', ok(Reviewer)), 
    !. 
0

我张贴this answer到您链接到的问题,但它可能会导致你在正确的方向:

我为我们的Gerrit安装编写了这个序言过滤器。我在父项目中做了一个submit_filter,因为我希望它适用于我们系统中的所有项目。

%filter to require all projects to have a code-reviewer other than the owner 
submit_filter(In, Out) :- 
    %unpack the submit rule into a list of code reviews 
    In =.. [submit | Ls], 
    %add the non-owner code review requiremet 
    reject_self_review(Ls, R), 
    %pack the list back up and return it (kinda) 
    Out =.. [submit | R]. 

reject_self_review(S1, S2) :- 
    %set O to be the change owner 
    gerrit:change_owner(O), 
    %find a +2 code review, if it exists, and set R to be the reviewer 
    gerrit:commit_label(label('Code-Review', 2), R), 
    %if there is a +2 review from someone other than the owner, then the filter has no work to do, assign S2 to S1 
    R \= O, !, 
    %the cut (!) predicate prevents further rules from being consulted 
    S2 = S1. 
reject_self_review(S1, S2) :- 
    %set O to be the change owner 
    gerrit:change_owner(O), 
    find a +2 code review, if it exists, and set R to be the reviewer 
    gerrit:commit_label(label('Code-Review', 2), R), 
    R = O, !, 
    %if there isn't a +2 from someone else (above rule), and there is a +2 from the owner, reject with a self-reviewed label 
    S2 = [label('Self-Reviewed', reject(O))|S1]. 
%if the above two rules didn't make it to the ! predicate, there aren't any +2s so let the default rules through unfiltered 
reject_self_review(S1, S1). 

此规则在rule #8 from the cookbook的好处(IMO)是:

  • 当所述变化被阻止的Self-Reviewed标签中仅示出,而不是添加Non-Author-Code-Review标签变化
  • 通过使用reject(O)该规则导致Self-Reviewed标签字面上成为红色标志
  • 作为submit_filter代替submit_rule,这个规则被安装在一个父项目,并适用于所有的子项目

请注意:此规则编写,以防止自我审查的变化Owner,而例如从食谱与Author比较。根据您的工作流程,您可能需要使用gerrit:commit_author(O)或​​