gerrt自定義Review Labels

gerrit 默認提供2個label。


Label: Code-Review
他的值可以是 -2  ~  +2 之間

-2表示 這個提交不應該被合入,
-1
0
+1
+2 只有+2了之後這個提交才能被合入,也就是submit那個按鈕纔會出現。 Any +2 enables submit
Label: Verified

 -1 Fails

    Tried to compile, but got a compile error, or tried to run tests, but one or more tests did not pass.

    Any -1 blocks submit.


0 No score

    Didn’t try to perform the verification tasks.


+1 Verified

    Compiled (and ran tests) successfully.

    Any +1 enables submit.


這2個標籤都是在All-Projects倉庫的refs/meta/config 下面的 project.config 文件中配置的。

[label "Code-Review"]
    function = MaxWithBlock
    copyMinScore = true
    value = -2 This shall not be merged
    value = -1 I would prefer this is not merged as is
    value =  0 No score
    value = +1 Looks good to me, but someone else must approve
    value = +2 Looks good to me, approved
[label "Verified"]
    value = -1 Fails
    value =  0 No score
    value = +1 Verified

當然我們可以自己添加 自定義的 標籤


label.Label-Name

        The name for a label, consisting only of alphanumeric characters and -.

label.Label-Name.value

        A multi-valued key whose values are of the form "<#> Value description text". The <#> may be any positive or negative number with an optional leading +.

label.Label-Name.defaultValue

        The default value (or score) for the label. The defaultValue must be within the range of valid label values. It is an optional label setting, if not defined the defaultValue for the label will be 0. When a defaultValue is defined, that value will get set in the Reply dialog by default.

        A defaultValue can be set to a score that is outside of the permissible range for a user. In that case the score that will get set in the Reply box will be either the lowest or highest score in the permissible range.

label.Label-Name.function

        The name of a function for evaluating multiple votes for a label. This function is only applied if the default submit rule is used for a label. If you write a custom submit rule (and do not call the default rule), the function name is ignored and may be treated as optional.

Valid values are:

    MaxWithBlock (default)

    The lowest possible negative value, if present, blocks a submit, while the highest possible positive value is required to enable submit. There must be at least one positive value, or else submit will never be enabled. To permit blocking submits, ensure a negative value is defined.

    AnyWithBlock

    The label is not mandatory but the lowest possible negative value, if present, blocks a submit. To permit blocking submits, ensure that a negative value is defined.

    MaxNoBlock

    The highest possible positive value is required to enable submit, but the lowest possible negative value will not block the change.

    NoBlock/NoOp

    The label is purely informational and values are not considered when determining whether a change is submittable.

    PatchSetLock

    The PatchSetLock function provides a locking mechanism for patch sets. This function’s values are not considered when determining whether a change is submittable. When set, no new patchsets can be created and rebase and abandon are blocked.

    This function is designed to allow overlapping locks, so several lock accounts could lock the same change.

    Allowed range of values are 0 (Patch Set Unlocked) to 1 (Patch Set Locked).

label.Label-Name.allowPostSubmit

        If true, the label may be voted on for changes that have already been submitted. If false, the label will not appear in the UI and will not be accepted when reviewing a closed change.

        In either case, voting on a label after submission is only permitted if the new vote is at least as high as the old vote by that user. This avoids creating the false impression that a post-submit vote can change the past and affect submission somehow.

        Defaults to true.

label.Label-Name.copyMinScore

        If true, the lowest possible negative value for the label is copied forward when a new patch set is uploaded. Defaults to false, except for All-Projects which has it true by default.

label.Label-Name.copyMaxScore

        If true, the highest possible positive value for the label is copied forward when a new patch set is uploaded. This can be used to enable sticky approvals, reducing turn-around for trivial cleanups prior to submitting a change. Defaults to false.
        label.Label-Name.copyAllScoresOnMergeFirstParentUpdate

        This policy is useful if you don’t want to trigger CI or human verification again if your target branch moved on but the feature branch being merged into the target branch did not change. It only applies if the patch set is a merge commit.

        If true, all scores for the label are copied forward when a new patch set is uploaded that is a new merge commit which only differs from the previous patch set in its first parent, or has identical parents. The first parent would be the parent of the merge commit that is part of the change’s target branch, whereas the other parent(s) refer to the feature branch(es) to be merged.

        Defaults to false.

label.Label-Name.copyAllScoresOnTrivialRebase

        If true, all scores for the label are copied forward when a new patch set is uploaded that is a trivial rebase. A new patch set is considered as trivial rebase if the commit message is the same as in the previous patch set and if it has the same code delta as the previous patch set. This is the case if the change was rebased onto a different parent, or if the parent did not change at all.

        This can be used to enable sticky approvals, reducing turn-around for trivial rebases prior to submitting a change. For the pre-installed Code-Review label this is enabled by default.

        Defaults to false.

label.Label-Name.copyAllScoresIfNoCodeChange

    If true, all scores for the label are copied forward when a new patch set is uploaded that has the same parent tree as the previous patch set and the same code delta as the previous patch set. This means only the commit message is different. This can be used to enable sticky approvals on labels that only depend on the code, reducing turn-around if only the commit message is changed prior to submitting a change. For the Verified label that is optionally installed by the init site program this is enabled by default.

    Defaults to false.
label.Label-Name.copyAllScoresIfNoChange

If true, all scores for the label are copied forward when a new patch set is uploaded that has the same parent tree, code delta, and commit message as the previous patch set. This means that only the patch set SHA1 is different. This can be used to enable sticky approvals, reducing turn-around for this special case. It is recommended to leave this enabled for both Verified and Code-Review labels.

Defaults to true.
label.Label-Name.canOverride

If false, the label cannot be overridden by child projects. Any configuration for this label in child projects will be ignored. Defaults to true.
label.Label-Name.branch

By default a given project’s label applicable scope is all changes on all branches of this project and its child projects.

Label’s applicable scope can be branch specific via configuration. E.g. create a label Video-Qualify on parent project and configure the branch as:

  [label "Video-Qualify"]
      branch = refs/heads/video-1.0/*
      branch = refs/heads/video-1.1/Kino

Then only changes in above branch scope of parent project and child projects will be affected by Video-Qualify.

Note
    The branch is independent from the branch scope defined in access parts in project.config file. That means from the UI a user can always assign permissions for that label on a branch, but this permission is then ignored if the label doesn’t apply for that branch. Additionally, the branch modifier has no effect when the submit rule is customized in the rules.pl of the project or inherited from parent projects. Branch can be a ref pattern similar to what is documented here, but must not contain ${username} or ${shardeduserid}. 

一個例子
To define a new 3-valued category that behaves exactly like Verified, but has different names/labels:

[label "Copyright-Check"]
      function = MaxWithBlock
      value = -1 Do not have copyright
      value = 0 No score
      value = +1 Copyright clear
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章