Closed flokli closed 2 years ago
LGTM (well, I wrote it :wink:)
Based on the specific configuration of an instance you may also not see this label on instances where it is present in the config (e.g. if it's not indicated as may(_)
in prolog rules). In TVL the behaviour of gerrit-queue in that case is that its submittability criteria don't trigger and nothing happens.
Yeah, I was referring to the logic not being very approachable. I added a unit test which exercises the IsAutosubmit
function with various goGerrit.ChangeInfo
(or more correct, the resulting Changeset
) structs.
@tazjin how do you configure gerrit to only allow owners to set the label? is that rules.pl as well?
I added something to the docs, but it's a bit squishy - would love to have a more correct explanation there.
Thanks for linking to these CLs! I added some docs on how to configure it in the README.md - and by this, realized the label normally is configured to only be 0 or -1.
How does a goGerrit.ChangeInfo
look like if the value is set to 0 (either keeping the default, or explicitly toggled to 1 and then 0 again)? Is the label simply not present?
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#_fields_set_by_code_labels_code doesn't seem to be too verbose in how this is expressed…
It suggests we should look in the value
if it's not +1
or -1
, and that doesn't seem to match what labelInfoToInt
is doing…
My take is that the only assumption you can make is that Autosubmit = 1
means "please autosubmit". Your labelInfoToInt
function returns that value correctly, everything else it may or may not return doesn't matter.
Any other case (e.g. label not being present, label being set to 42 or -17, label being present at 0 but with may(_)
or need(_)
, ...) is custom logic of the Gerrit instance and not something you can rely on for any logic.
Yes, for the Autosubmit functionality, only a ChangeInfo with the "Autosubmit" label info and an "Approved" will have labelInfoToInt
return 1
, which will cause IsAutosubmit()
to return true.
However, all labels with values != [-2, -1, 0,1, 2] will apparently cause labelInfoToInt
to return 0
, which is wrong. I added a comment to the labelInfoToInt
function to document this.
This moves to using a Gerrit label ('Autosubmit') with boolean values for determining whether a developer wants to have a change automatically submitted.
See also https://cl.tvl.fyi/c/depot/+/4172