blob: cf78c6d892634a0be5c7e956df1931917413ddc2 [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
241created and rebase and abandon are blocked.
242+
243This function is designed to allow overlapping locks, so several lock
244accounts could lock the same change.
245+
246Allowed range of values are 0 (Patch Set Unlocked) to 1 (Patch Set
247Locked).
248
Dave Borowitz20d71e52016-11-15 17:02:16 -0800249[[label_allowPostSubmit]]
250=== `label.Label-Name.allowPostSubmit`
251
252If true, the label may be voted on for changes that have already been
253submitted. If false, the label will not appear in the UI and will not
254be accepted when reviewing a closed change.
255
256In either case, voting on a label after submission is only permitted if
257the new vote is at least as high as the old vote by that user. This
258avoids creating the false impression that a post-submit vote can change
259the past and affect submission somehow.
260
261Defaults to true.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800262
263[[label_copyMinScore]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800264=== `label.Label-Name.copyMinScore`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800265
266If true, the lowest possible negative value for the label is copied
Marco Miller5f834712015-03-13 17:20:44 -0400267forward when a new patch set is uploaded. Defaults to false, except
268for All-Projects which has it true by default.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800269
Shawn Pearcea7c4a3a2013-03-26 15:58:51 -0400270[[label_copyMaxScore]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800271=== `label.Label-Name.copyMaxScore`
Shawn Pearcea7c4a3a2013-03-26 15:58:51 -0400272
273If true, the highest possible positive value for the label is copied
274forward when a new patch set is uploaded. This can be used to enable
275sticky approvals, reducing turn-around for trivial cleanups prior to
Marco Miller5f834712015-03-13 17:20:44 -0400276submitting a change. Defaults to false.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800277
Maxime Guerreiroafda80f2018-05-25 09:38:35 +0000278[[label_copyAllScoresOnMergeFirstParentUpdate]]
279=== `label.Label-Name.copyAllScoresOnMergeFirstParentUpdate`
Dariusz Lukszacedbbee2016-01-29 12:06:20 +0100280
281This policy is useful if you don't want to trigger CI or human
282verification again if your target branch moved on but the feature
283branch being merged into the target branch did not change. It only
284applies if the patch set is a merge commit.
285
286If true, all scores for the label are copied forward when a new
287patch set is uploaded that is a new merge commit which only
Dave Borowitz2878bb52016-02-08 09:44:32 -0500288differs from the previous patch set in its first parent, or has
289identical parents. The first parent would be the parent of the merge
290commit that is part of the change's target branch, whereas the other
291parent(s) refer to the feature branch(es) to be merged.
292
Dariusz Lukszacedbbee2016-01-29 12:06:20 +0100293Defaults to false.
294
Edwin Kempinf5c08412013-09-18 09:41:01 +0200295[[label_copyAllScoresOnTrivialRebase]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800296=== `label.Label-Name.copyAllScoresOnTrivialRebase`
Edwin Kempinf5c08412013-09-18 09:41:01 +0200297
298If true, all scores for the label are copied forward when a new patch
299set is uploaded that is a trivial rebase. A new patch set is considered
300as trivial rebase if the commit message is the same as in the previous
301patch set and if it has the same code delta as the previous patch set.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500302This is the case if the change was rebased onto a different parent, or
303if the parent did not change at all.
304
Edwin Kempinf5c08412013-09-18 09:41:01 +0200305This can be used to enable sticky approvals, reducing turn-around for
Zalan Blenessyae476862015-02-13 14:06:57 +0100306trivial rebases prior to submitting a change.
Edwin Kempin09f7f7b2015-04-28 10:43:26 +0200307For the pre-installed Code-Review label this is enabled by default.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500308
Zalan Blenessyae476862015-02-13 14:06:57 +0100309Defaults to false.
Edwin Kempinf5c08412013-09-18 09:41:01 +0200310
Edwin Kempin54122d32013-09-18 13:46:14 +0200311[[label_copyAllScoresIfNoCodeChange]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800312=== `label.Label-Name.copyAllScoresIfNoCodeChange`
Edwin Kempin54122d32013-09-18 13:46:14 +0200313
314If true, all scores for the label are copied forward when a new patch
Zalan Blenessyae476862015-02-13 14:06:57 +0100315set is uploaded that has the same parent tree as the previous patch
Edwin Kempin54122d32013-09-18 13:46:14 +0200316set and the same code delta as the previous patch set. This means only
317the commit message is different. This can be used to enable sticky
318approvals on labels that only depend on the code, reducing turn-around
319if only the commit message is changed prior to submitting a change.
Gert van Dijkbc683f22017-08-28 01:30:47 +0200320For the Verified label that is optionally installed by the
321link:pgm-init.html[init] site program this is enabled by default.
Dave Borowitz2878bb52016-02-08 09:44:32 -0500322
Edwin Kempin54122d32013-09-18 13:46:14 +0200323Defaults to false.
324
Zalan Blenessyae476862015-02-13 14:06:57 +0100325[[label_copyAllScoresIfNoChange]]
326=== `label.Label-Name.copyAllScoresIfNoChange`
327
328If true, all scores for the label are copied forward when a new patch
329set is uploaded that has the same parent tree, code delta, and commit
330message as the previous patch set. This means that only the patch
331set SHA1 is different. This can be used to enable sticky
332approvals, reducing turn-around for this special case.
333It is recommended to leave this enabled for both Verified and
Dave Borowitz2878bb52016-02-08 09:44:32 -0500334Code-Review labels.
335
336Defaults to true.
Zalan Blenessyae476862015-02-13 14:06:57 +0100337
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800338[[label_canOverride]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800339=== `label.Label-Name.canOverride`
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800340
341If false, the label cannot be overridden by child projects. Any
342configuration for this label in child projects will be ignored. Defaults
343to true.
344
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800345[[label_branch]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800346=== `label.Label-Name.branch`
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800347
348By default a given project's label applicable scope is all changes
349on all branches of this project and its child projects.
350
351Label's applicable scope can be branch specific via configuration.
352E.g. create a label `Video-Qualify` on parent project and configure
353the `branch` as:
354
Michael Ochmannb99feab2016-07-06 14:10:22 +0200355----
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800356 [label "Video-Qualify"]
357 branch = refs/heads/video-1.0/*
358 branch = refs/heads/video-1.1/Kino
Michael Ochmannb99feab2016-07-06 14:10:22 +0200359----
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800360
361Then *only* changes in above branch scope of parent project and child
362projects will be affected by `Video-Qualify`.
363
Michael Ochmann8129ece2016-07-08 11:25:25 +0200364[NOTE]
365The `branch` is independent from the branch scope defined in `access`
Bruce Zu9b22c3a2013-09-06 01:23:03 +0800366parts in `project.config` file. That means from the UI a user can always
367assign permissions for that label on a branch, but this permission is then
368ignored if the label doesn't apply for that branch.
Luca Milanesio4ab75822017-05-31 17:44:49 +0100369Additionally, the `branch` modifier has no effect when the submit rule
370is customized in the rules.pl of the project or inherited from parent projects.
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800371
372[[label_example]]
Yuxuan 'fishy' Wang61698b12013-12-20 12:55:51 -0800373=== Example
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800374
375To define a new 3-valued category that behaves exactly like `Verified`,
376but has different names/labels:
377
Michael Ochmannb99feab2016-07-06 14:10:22 +0200378----
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800379 [label "Copyright-Check"]
Edwin Kempinba8cdd82013-04-03 15:35:06 +0200380 function = MaxWithBlock
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800381 value = -1 Do not have copyright
Dave Borowitz085209e2017-11-20 15:18:15 -0500382 value = 0 No score
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800383 value = +1 Copyright clear
Michael Ochmannb99feab2016-07-06 14:10:22 +0200384----
Dave Borowitz01c1b1f2013-02-27 13:49:04 -0800385
386The new column will appear at the end of the table, and `-1 Do not have
387copyright` will block submit, while `+1 Copyright clear` is required to
388enable submit.
Edwin Kempin5beb89d2013-03-15 08:03:12 +0100389
Khai Do4c91b002014-04-06 23:27:43 -0700390=== Default Value Example
391
392This example attempts to describe how a label default value works with the
393user permissions. Assume the configuration below.
394
Michael Ochmannb99feab2016-07-06 14:10:22 +0200395----
Khai Do4c91b002014-04-06 23:27:43 -0700396 [access "refs/heads/*"]
397 label-Snarky-Review = -3..+3 group Administrators
398 label-Snarky-Review = -2..+2 group Project Owners
399 label-Snarky-Review = -1..+1 group Registered Users
400 [label "Snarky-Review"]
401 value = -3 Ohh, hell no!
402 value = -2 Hmm, I'm not a fan
403 value = -1 I'm not sure I like this
Dave Borowitz085209e2017-11-20 15:18:15 -0500404 value = 0 No score
Khai Do4c91b002014-04-06 23:27:43 -0700405 value = +1 I like, but need another to like it as well
406 value = +2 Hmm, this is pretty nice
407 value = +3 Ohh, hell yes!
408 defaultValue = -3
Michael Ochmannb99feab2016-07-06 14:10:22 +0200409----
Khai Do4c91b002014-04-06 23:27:43 -0700410
411Upon clicking the Reply button:
Edwin Kempinec7397e2015-04-07 09:34:56 +0200412
Khai Do4c91b002014-04-06 23:27:43 -0700413* Administrators have all scores (-3..+3) available, -3 is set as the default.
414* Project Owners have limited scores (-2..+2) available, -2 is set as the default.
415* Registered Users have limited scores (-1..+1) available, -1 is set as the default.
416
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500417=== Patch Set Lock Example
418
419This example shows how a label can be configured to have a standard patch set lock.
420
Michael Ochmannb99feab2016-07-06 14:10:22 +0200421----
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500422 [access "refs/heads/*"]
423 label-Patch-Set-Lock = +0..+1 group Administrators
424 [label "Patch-Set-Lock"]
425 function = PatchSetLock
426 value = 0 Patch Set Unlocked
427 value = +1 Patch Set Locked
428 defaultValue = 0
Michael Ochmannb99feab2016-07-06 14:10:22 +0200429----
Alexandre Philbertb7d3c722016-01-28 09:04:06 -0500430
Edwin Kempin5beb89d2013-03-15 08:03:12 +0100431GERRIT
432------
433Part of link:index.html[Gerrit Code Review]
Yuxuan 'fishy' Wang99cb68d2013-10-31 17:26:00 -0700434
435SEARCHBOX
436---------