Labels & Prolog-Less Submit Rules
Control when changes become submittable
(Edwin Kempin, Google)
Agenda
When is a change submittable?
?
When is a change submittable?
When is a change submittable?
When is a change submittable?
When is a change submittable?
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
When is a change submittable?
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
When is a change submittable?
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
When is a change submittable?
Hard-coded in Gerrit
Label Configuration (DefaultSubmitRule)
SubmitRules
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
Where are Prolog submit rules?
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
Where are Prolog submit rules?
Prolog Submit Rules (PrologRule)
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
Label Configuration
(details in Gerrit docs)
Label Configuration
Label Configuration (DefaultSubmitRule)
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
File project.config in refs/meta/config:
Label Configuration - Example�
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval
File project.config in refs/meta/config:
Label Configuration - Example�
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval
Label Functions�
* Approval = highest possible vote�** Veto = lowest possible vote
Function | Approval required | Veto possible |
MaxWithBlock (default) | | |
AnyWithBlock | | |
MaxNoBlock | | |
NoBlock | | |
Restrict Label to Branch�
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval� branch = refs/heads/stable/*
Sticky Labels
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval� copyMinScore = true
Copy Rules�
* Veto = lowest possible vote
** Approval = highest possible vote
*** Trivial Rebase = same commit message and same code diff
Copy Rule | Behavior |
copyMinScore | Makes vetos* sticky. |
copyMaxScore | Makes approvals** sticky. |
copyAllScoresIfNoCodeChange | Makes votes sticky if only the commit message was changed. |
copyAllScoresOnTrivialRebase | Makes votes sticky if the new patch set was a trivial rebase*** of the old patch set. |
Label Inheritance
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval
Parent
Child
Label Inheritance
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval
Parent
Child
[label "MyLabel"]� function = MaxWithBlock� value = -2 Veto� value = -1 Please fix� value = 0 No score� value = +1 LGTM� value = +2 Approval
Label Inheritance
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval
Parent
Child
[label "MyLabel"]
Label Inheritance
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval� canOverride = false
Parent
Child
[label "MyLabel"]
Ignored
�
Limitations of Labels
Limitations of Labels
⇒ Submit Rules�
Submit Rules vs. Checks
Submit Rules | Checks |
Supported by Gerrit core. | Need checks plugin. |
Run inside Gerrit process. | Run outside of Gerrit process (on CI server). |
Executed when submittability of a change is checked. | Executed (at most) once per patch set. |
Synchronous. | Asynchronous. |
One submit requirement per submit rule. | One aggregated result per change. |
Submit Rules for Checks
SubmitRules
ChecksSubmitRule
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
Prolog-less Submit Rule
(details in Gerrit docs)
Prolog-less Submit Rules
SubmitRules
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
SubmitRule Extension Point
Shown interface is from master (aka Gerrit 3.1).�Exists since 2.16, but looks slightly different there.
Example: No Unresolved Comments
Full code can be found in the simple-submit-rule plugin.
Example: No Unresolved Comments
Full code can be found in the simple-submit-rule plugin.
Example: No Unresolved Comments
Full code can be found in the simple-submit-rule plugin.
Example: No Unresolved Comments
Full code can be found in the simple-submit-rule plugin.
Example: No Unresolved Comments
Full code can be found in the simple-submit-rule plugin.
Example: No Unresolved Comments
The result of the SubmitRule is shown here
simple-submit-rules Plugin
simple-submit-rules Plugin
[label "MyLabel"]� function = MaxWithBlock� value = -1 Veto� value = 0 No score� value = +1 Approval� ignoreSelfApproval = true
Results from multiple Submit Rules
SubmitRule: Handling of Inheritance
Also look at the project configuration of parent projects
Limitations of Submit Rules
Why not Prolog?
Why not Prolog?
Prolog Submit Rules (PrologRule)
* if submit type != CHERRY_PICK�** if change.submitWholeTopic = true
Why not Prolog?
Future Work
Possible Future Work*
*Wishlist, currently nobody is actively working on these points..
Questions?