blob: ff4352096265ff024a1e78adf0f5536424dcf36c [file] [log] [blame]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -08001= Gerrit Code Review - Review Labels
Dave Borowitz01c1b1f2013-02-27 13:49:04 -08002
3As part of the code review process, reviewers score each change with
4values for each label configured for the project. The label values that
5a given user is allowed to set are defined according to the
Fredrik Luthanderac8af9e2013-05-08 01:06:25 +02006link:access-control.html#category_review_labels[access controls]. Gerrit
7comes pre-configured with the Code-Review label that can be granted to
8groups within projects, enabling functionality for that group's members.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -08009
10
Dave Borowitz01c1b1f2013-02-27 13:49:04 -080011[[label_Code-Review]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080012== Label: Code-Review
Dave Borowitz01c1b1f2013-02-27 13:49:04 -080013
Gert van Dijkbc683f22017-08-28 01:30:47 +020014The Code-Review label is configured upon the creation of a Gerrit
15instance. It may have any meaning the project desires. It was
16originally invented by the Android Open Source Project to mean
17'I read the code and it seems reasonably correct'.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -080018
19The range of values is:
20
Paul Fertser2474e522014-01-23 10:00:59 +040021* -2 This shall not be merged
Dave Borowitz01c1b1f2013-02-27 13:49:04 -080022+
23The code is so horribly incorrect/buggy/broken that it must not be
24submitted to this project, or to this branch. This value is valid
25across all patch sets in the same change, i.e. the reviewer must
26actively change his/her review to something else before the change
27is submittable.
28+
29*Any -2 blocks submit.*
30
Paul Fertser2474e522014-01-23 10:00:59 +040031* -1 I would prefer this is not merged as is
Dave Borowitz01c1b1f2013-02-27 13:49:04 -080032+
33The code doesn't look right, or could be done differently, but
34the reviewer is willing to live with it as-is if another reviewer
35accepts it, perhaps because it is better than what is currently in
36the project. Often this is also used by contributors who don't like
37the change, but also aren't responsible for the project long-term
38and thus don't have final say on change submission.
39+
40Does not block submit.
41
42* 0 No score
43+
44Didn't try to perform the code review task, or glanced over it but
45don't have an informed opinion yet.
46
47* +1 Looks good to me, but someone else must approve
48+
49The code looks right to this reviewer, but the reviewer doesn't
50have access to the `+2` value for this category. Often this is
51used by contributors to a project who were able to review the change
52and like what it is doing, but don't have final approval over what
53gets submitted.
54
55* +2 Looks good to me, approved
56+
57Basically the same as `+1`, but for those who have final say over
58how the project will develop.
59+
60*Any +2 enables submit.*
61
62For a change to be submittable, the latest patch set must have a
63`+2 Looks good to me, approved` in this category, and no
64`-2 Do not submit`. Thus `-2` on any patch set can block a submit,
65while `+2` on the latest patch set can enable it.
66
67If a Gerrit installation does not wish to use this label in any project,
68the `[label "Code-Review"]` section can be deleted from `project.config`
69in `All-Projects`.
70
71If a Gerrit installation or project wants to modify the description text
72associated with these label values, the text can be updated in the
73`label.Code-Review.value` fields in `project.config`.
74
75Additional entries could be added to `label.Code-Review.value` to
76further extend the negative and positive range, but there is likely
77little value in doing so as this only expands the middle region. This
78label is a `MaxWithBlock` type, which means that the lowest negative
79value if present blocks a submit, while the highest positive value is
80required to enable submit.
81
Shawn Pearce77d96622013-03-28 18:02:19 -040082[[label_Verified]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -080083== Label: Verified
Shawn Pearce77d96622013-03-28 18:02:19 -040084
85The Verified label was originally invented by the Android Open Source
86Project to mean 'compiles, passes basic unit tests'. Some CI tools
87expect to use the Verified label to vote on a change after running.
88
Gert van Dijkbc683f22017-08-28 01:30:47 +020089During site initialization the administrator may have chosen to
90configure the default Verified label for all projects. In case it is
91desired to configure it at a later time, administrators can do this by
92adding the following to `project.config` in `All-Projects`:
Shawn Pearce77d96622013-03-28 18:02:19 -040093
Michael Ochmannb99feab2016-07-06 14:10:22 +020094----
Shawn Pearce77d96622013-03-28 18:02:19 -040095 [label "Verified"]
Edwin Kempinba8cdd82013-04-03 15:35:06 +020096 function = MaxWithBlock
Shawn Pearce77d96622013-03-28 18:02:19 -040097 value = -1 Fails
Dave Borowitz085209e2017-11-20 15:18:15 -050098 value = 0 No score
Shawn Pearce77d96622013-03-28 18:02:19 -040099 value = +1 Verified
Gert van Dijkbc683f22017-08-28 01:30:47 +0200100 copyAllScoresIfNoCodeChange = true
Michael Ochmannb99feab2016-07-06 14:10:22 +0200101----
Shawn Pearce77d96622013-03-28 18:02:19 -0400102
103The range of values is:
104
105* -1 Fails
106+
107Tried to compile, but got a compile error, or tried to run tests,
108but one or more tests did not pass.
109+
110*Any -1 blocks submit.*
111
112* 0 No score
113+
114Didn't try to perform the verification tasks.
115
116* +1 Verified
117+
118Compiled (and ran tests) successfully.
119+
120*Any +1 enables submit.*
121
122For a change to be submittable, the change must have a `+1 Verified`
123in this label, and no `-1 Fails`. Thus, `-1 Fails` can block a submit,
124while `+1 Verified` enables a submit.
125
126Additional values could also be added to this label, to allow it to
127behave more like `Code-Review` (below). Add -2 and +2 entries to the
128`label.Verified.value` fields in `project.config` to get the same
129behavior.
130
131
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800132[[label_custom]]
David Pursehouse584aa192017-02-28 16:28:43 +0900133== Customized Labels
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800134
David Pursehouse584aa192017-02-28 16:28:43 +0900135Site administrators and project owners can define their own labels,
136or customize labels inherited from parent projects.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800137
138See above for descriptions of how <<label_Verified,`Verified`>>
139and <<label_Code-Review,`Code-Review`>> work, and add your own
140label to `project.config` to get the same behavior over your own range
141of values, for any label you desire.
142
143Just like the built-in labels, users need to be given permissions to
144vote on custom labels. Permissions can either be added by manually
145editing project.config when adding the labels, or, once the labels are
146added, permission categories for those labels will show up in the
147permission editor web UI.
148
149Labels may be added to any project's `project.config`; the default
David Pursehouse584aa192017-02-28 16:28:43 +0900150labels are defined in `All-Projects`.
151
152[[label_inheritance]]
153=== Inheritance
154
155Labels are inherited from parent projects. A child project may add,
David Pursehouse9c333f02017-02-28 16:35:27 +0900156override, or remove labels defined in its parents.
157
158Overriding a label in a child project overrides all its properties and
159values. It is not possible to modify an inherited label by adding
160properties in the child project's configuration; all properties from
161the parent definition must be redefined in the child.
162
163To remove a label in a child project, add an empty label with the same
Han-Wen Nienhuysf6b0bb82018-04-23 16:38:44 +0200164name as in the parent. This will override the parent label with
165a label containing the defaults (`function = MaxWithBlock`,
166`defaultValue = 0` and no further allowed values)
David Pursehouse584aa192017-02-28 16:28:43 +0900167
168[[label_layout]]
169=== Layout
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800170
Nigel Babu46bb5c72017-12-19 11:21:32 +0530171Labels are laid out in alphabetical order.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800172
173[[label_name]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800174=== `label.Label-Name`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800175
176The name for a label, consisting only of alphanumeric characters and
177`-`.
178
179
180[[label_value]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800181=== `label.Label-Name.value`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800182
183A multi-valued key whose values are of the form `"<#> Value description
184text"`. The `<#>` may be any positive or negative number with an
185optional leading `+`.
186
187
Khai Do4c91b002014-04-06 23:27:43 -0700188[[label_defaultValue]]
189=== `label.Label-Name.defaultValue`
190
191The default value (or score) for the label. The defaultValue must be
192within the range of valid label values. It is an optional label setting,
193if not defined the defaultValue for the label will be 0. When a
194defaultValue is defined, that value will get set in the Reply dialog
195by default.
196
197A defaultValue can be set to a score that is outside of the permissible
198range for a user. In that case the score that will get set in the Reply
199box will be either the lowest or highest score in the permissible range.
200
201
Edwin Kempinba8cdd82013-04-03 15:35:06 +0200202[[label_function]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800203=== `label.Label-Name.function`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800204
205The name of a function for evaluating multiple votes for a label. This
206function is only applied if the default submit rule is used for a label.
207If you write a link:prolog-cookbook.html#HowToWriteSubmitRules[custom
208submit rule] (and do not call the default rule), the function name is
209ignored and may be treated as optional.
210
211Valid values are:
212
213* `MaxWithBlock` (default)
214+
215The lowest possible negative value, if present, blocks a submit, while
216the highest possible positive value is required to enable submit. There
217must be at least one positive value, or else submit will never be
218enabled. To permit blocking submits, ensure a negative value is defined.
219
Khai Dod44ea942013-07-31 07:45:17 -0700220* `AnyWithBlock`
221+
Maxime Guerreiroc2750892018-03-16 15:05:36 +0100222The label is not mandatory but the lowest possible negative value,
223if present, blocks a submit. To permit blocking submits, ensure that a
224negative value is defined.
Khai Dod44ea942013-07-31 07:45:17 -0700225
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800226* `MaxNoBlock`
227+
228The highest possible positive value is required to enable submit, but
229the lowest possible negative value will not block the change.
230
231* `NoBlock`/`NoOp`
232+
233The label is purely informational and values are not considered when
234determining whether a change is submittable.
235
Nasser Grainawi240ea292015-11-09 09:56:56 -0800236* `PatchSetLock`
237+
238The `PatchSetLock` function provides a locking mechanism for patch
239sets. This function's values are not considered when determining
240whether a change is submittable. When set, no new patchsets can be
Han-Wen Nienhuys159f03b2018-08-07 19:26:58 +0200241created and rebase and abandon are blocked. This is useful to prevent
242updates to a change while (potentially expensive) CI
243validation is running.
Nasser Grainawi240ea292015-11-09 09:56:56 -0800244+
245This function is designed to allow overlapping locks, so several lock
246accounts could lock the same change.
247+
248Allowed range of values are 0 (Patch Set Unlocked) to 1 (Patch Set
249Locked).
250
Dave Borowitz20d71e52016-11-15 17:02:16 -0800251[[label_allowPostSubmit]]
252=== `label.Label-Name.allowPostSubmit`
253
254If true, the label may be voted on for changes that have already been
255submitted. If false, the label will not appear in the UI and will not
256be accepted when reviewing a closed change.
257
258In either case, voting on a label after submission is only permitted if
259the new vote is at least as high as the old vote by that user. This
260avoids creating the false impression that a post-submit vote can change
261the past and affect submission somehow.
262
263Defaults to true.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800264
265[[label_copyMinScore]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800266=== `label.Label-Name.copyMinScore`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800267
268If true, the lowest possible negative value for the label is copied
Marco Miller5f834712015-03-13 17:20:44 -0400269forward when a new patch set is uploaded. Defaults to false, except
270for All-Projects which has it true by default.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800271
Shawn Pearcea7c4a3a2013-03-26 15:58:51 -0400272[[label_copyMaxScore]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800273=== `label.Label-Name.copyMaxScore`
Shawn Pearcea7c4a3a2013-03-26 15:58:51 -0400274
275If true, the highest possible positive value for the label is copied
276forward when a new patch set is uploaded. This can be used to enable
277sticky approvals, reducing turn-around for trivial cleanups prior to
Marco Miller5f834712015-03-13 17:20:44 -0400278submitting a change. Defaults to false.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800279
Maxime Guerreiroafda80f2018-05-25 09:38:35 +0000280[[label_copyAllScoresOnMergeFirstParentUpdate]]
281=== `label.Label-Name.copyAllScoresOnMergeFirstParentUpdate`
Dariusz Lukszacedbbee2016-01-29 12:06:20 +0100282
283This policy is useful if you don't want to trigger CI or human
284verification again if your target branch moved on but the feature
285branch being merged into the target branch did not change. It only
286applies if the patch set is a merge commit.
287
288If true, all scores for the label are copied forward when a new
289patch set is uploaded that is a new merge commit which only
Dave Borowitz2878bb52016-02-08 09:44:32 -0500290differs from the previous patch set in its first parent, or has
291identical parents. The first parent would be the parent of the merge
292commit that is part of the change's target branch, whereas the other
293parent(s) refer to the feature branch(es) to be merged.
294
Dariusz Lukszacedbbee2016-01-29 12:06:20 +0100295Defaults to false.
296
Edwin Kempinf5c08412013-09-18 09:41:01 +0200297[[label_copyAllScoresOnTrivialRebase]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800298=== `label.Label-Name.copyAllScoresOnTrivialRebase`
Edwin Kempinf5c08412013-09-18 09:41:01 +0200299
300If true, all scores for the label are copied forward when a new patch
301set is uploaded that is a trivial rebase. A new patch set is considered
302as trivial rebase if the commit message is the same as in the previous
303patch set and if it has the same code delta as the previous patch set.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500304This is the case if the change was rebased onto a different parent, or
305if the parent did not change at all.
306
Edwin Kempinf5c08412013-09-18 09:41:01 +0200307This can be used to enable sticky approvals, reducing turn-around for
Zalan Blenessyae476862015-02-13 14:06:57 +0100308trivial rebases prior to submitting a change.
Edwin Kempin09f7f7b2015-04-28 10:43:26 +0200309For the pre-installed Code-Review label this is enabled by default.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500310
Zalan Blenessyae476862015-02-13 14:06:57 +0100311Defaults to false.
Edwin Kempinf5c08412013-09-18 09:41:01 +0200312
Edwin Kempin54122d32013-09-18 13:46:14 +0200313[[label_copyAllScoresIfNoCodeChange]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800314=== `label.Label-Name.copyAllScoresIfNoCodeChange`
Edwin Kempin54122d32013-09-18 13:46:14 +0200315
316If true, all scores for the label are copied forward when a new patch
Zalan Blenessyae476862015-02-13 14:06:57 +0100317set is uploaded that has the same parent tree as the previous patch
Edwin Kempin54122d32013-09-18 13:46:14 +0200318set and the same code delta as the previous patch set. This means only
319the commit message is different. This can be used to enable sticky
320approvals on labels that only depend on the code, reducing turn-around
321if only the commit message is changed prior to submitting a change.
Gert van Dijkbc683f22017-08-28 01:30:47 +0200322For the Verified label that is optionally installed by the
323link:pgm-init.html[init] site program this is enabled by default.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500324
Edwin Kempin54122d32013-09-18 13:46:14 +0200325Defaults to false.
326
Zalan Blenessyae476862015-02-13 14:06:57 +0100327[[label_copyAllScoresIfNoChange]]
328=== `label.Label-Name.copyAllScoresIfNoChange`
329
330If true, all scores for the label are copied forward when a new patch
331set is uploaded that has the same parent tree, code delta, and commit
332message as the previous patch set. This means that only the patch
333set SHA1 is different. This can be used to enable sticky
334approvals, reducing turn-around for this special case.
335It is recommended to leave this enabled for both Verified and
Dave Borowitz2878bb52016-02-08 09:44:32 -0500336Code-Review labels.
337
338Defaults to true.
Zalan Blenessyae476862015-02-13 14:06:57 +0100339
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800340[[label_canOverride]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800341=== `label.Label-Name.canOverride`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800342
343If false, the label cannot be overridden by child projects. Any
344configuration for this label in child projects will be ignored. Defaults
345to true.
346
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800347[[label_branch]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800348=== `label.Label-Name.branch`
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800349
350By default a given project's label applicable scope is all changes
351on all branches of this project and its child projects.
352
353Label's applicable scope can be branch specific via configuration.
354E.g. create a label `Video-Qualify` on parent project and configure
355the `branch` as:
356
Michael Ochmannb99feab2016-07-06 14:10:22 +0200357----
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800358 [label "Video-Qualify"]
359 branch = refs/heads/video-1.0/*
360 branch = refs/heads/video-1.1/Kino
Michael Ochmannb99feab2016-07-06 14:10:22 +0200361----
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800362
363Then *only* changes in above branch scope of parent project and child
364projects will be affected by `Video-Qualify`.
365
Michael Ochmann8129ece2016-07-08 11:25:25 +0200366[NOTE]
367The `branch` is independent from the branch scope defined in `access`
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800368parts in `project.config` file. That means from the UI a user can always
369assign permissions for that label on a branch, but this permission is then
370ignored if the label doesn't apply for that branch.
Luca Milanesio4ab75822017-05-31 17:44:49 +0100371Additionally, the `branch` modifier has no effect when the submit rule
372is customized in the rules.pl of the project or inherited from parent projects.
Patrick Hiesel7e50ec92018-07-09 16:06:21 +0200373Branch can be a ref pattern similar to what is documented
374link:access-control.html#reference[here], but must not contain `${username}` or
375`${shardeduserid}`.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800376
Patrick Hiesel12c87c72018-09-03 13:19:08 +0200377[[label_ignoreSelfApproval]]
378=== `label.Label-Name.ignoreSelfApproval`
379
380If true, the label may be voted on by the uploader of the latest patch set,
381but their approval does not make a change submittable. Instead, a
382non-uploader who has the right to vote has to approve the change.
383
384Defaults to false.
385
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800386[[label_example]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800387=== Example
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800388
389To define a new 3-valued category that behaves exactly like `Verified`,
390but has different names/labels:
391
Michael Ochmannb99feab2016-07-06 14:10:22 +0200392----
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800393 [label "Copyright-Check"]
Edwin Kempinba8cdd82013-04-03 15:35:06 +0200394 function = MaxWithBlock
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800395 value = -1 Do not have copyright
Dave Borowitz085209e2017-11-20 15:18:15 -0500396 value = 0 No score
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800397 value = +1 Copyright clear
Michael Ochmannb99feab2016-07-06 14:10:22 +0200398----
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800399
400The new column will appear at the end of the table, and `-1 Do not have
401copyright` will block submit, while `+1 Copyright clear` is required to
402enable submit.
Edwin Kempin5beb89d2013-03-15 08:03:12 +0100403
Khai Do4c91b002014-04-06 23:27:43 -0700404=== Default Value Example
405
406This example attempts to describe how a label default value works with the
407user permissions. Assume the configuration below.
408
Michael Ochmannb99feab2016-07-06 14:10:22 +0200409----
Khai Do4c91b002014-04-06 23:27:43 -0700410 [access "refs/heads/*"]
411 label-Snarky-Review = -3..+3 group Administrators
412 label-Snarky-Review = -2..+2 group Project Owners
413 label-Snarky-Review = -1..+1 group Registered Users
414 [label "Snarky-Review"]
415 value = -3 Ohh, hell no!
416 value = -2 Hmm, I'm not a fan
417 value = -1 I'm not sure I like this
Dave Borowitz085209e2017-11-20 15:18:15 -0500418 value = 0 No score
Khai Do4c91b002014-04-06 23:27:43 -0700419 value = +1 I like, but need another to like it as well
420 value = +2 Hmm, this is pretty nice
421 value = +3 Ohh, hell yes!
422 defaultValue = -3
Michael Ochmannb99feab2016-07-06 14:10:22 +0200423----
Khai Do4c91b002014-04-06 23:27:43 -0700424
425Upon clicking the Reply button:
Edwin Kempinec7397e2015-04-07 09:34:56 +0200426
Khai Do4c91b002014-04-06 23:27:43 -0700427* Administrators have all scores (-3..+3) available, -3 is set as the default.
428* Project Owners have limited scores (-2..+2) available, -2 is set as the default.
429* Registered Users have limited scores (-1..+1) available, -1 is set as the default.
430
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500431=== Patch Set Lock Example
432
433This example shows how a label can be configured to have a standard patch set lock.
434
Michael Ochmannb99feab2016-07-06 14:10:22 +0200435----
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500436 [access "refs/heads/*"]
437 label-Patch-Set-Lock = +0..+1 group Administrators
438 [label "Patch-Set-Lock"]
439 function = PatchSetLock
440 value = 0 Patch Set Unlocked
441 value = +1 Patch Set Locked
442 defaultValue = 0
Michael Ochmannb99feab2016-07-06 14:10:22 +0200443----
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500444
Edwin Kempin5beb89d2013-03-15 08:03:12 +0100445GERRIT
446------
447Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700448
449SEARCHBOX
450---------