Hello Gerriters,
We use Gerrit stream events extensively and we would like to see the label info (i.e. 'approvals' field) on every commentAdded event because we want our CI system to trigger off of that info[1]. Currently we cannot do that because the commentAdded event only provides the label info when there is a vote transition (or change):
review comment with no vote change -> commentAddedEvent does not contains label info
review comment with a vote change -> commentAddedEvent contains label info
My change proposal[2] was to simply add the label info to the event on every comment regardless of the vote. However the problem with this change is that it breaks things that look for the existence or absence of the label info as an indication of a changed vote (i.e. Jenkins gerrit-trigger plugin).
I think the fact that the gerrit-trigger plugin needs to depend on an implicit indicator to determine vote transitions is not real nice and can be buggy. My proposal to fix this is to add an explicit indicator to the commentAdded event for vote transitions so that things outside of gerrit can reliably determine that a vote has changed. So what would that event look like? Possible solutions:
A. Bjorn's proposal is to add a separate 'allLabels' field to the event. The 'approvals' continue to only be in commmentAdded events that contained a vote transition. The 'allLabels' field would appear in every commentAdded event showing the label and vote info.
Stream-event:
"approvals":[{"type":"Code-Review","description":"Code-Review","value":"-1"], "allLabels":[{"type":"Code-Review","value":"-1"}], "comment":"Patch Set 1: Code-Review+1\n\nbar"
Pros:
Preserves backwards compatibility with the gerrit-trigger pliugin and possibily other third party things.
Cons:
Introduce a small amount of duplicate information (but normally the number of labels per vote is small)
Vote transition indicator is still implicit.
Probably not a big deal, but makes event less concise.
B. Sven's proposal is to add an 'updated' field to the approvals list for every label. The 'approvals' list would be in every commentAdded event and include an 'updated' field to indicate whether a vote change occurred.
Stream-event:
"approvals":[{"type":"Code-Review","description":"Code-Review","value":"-1", "updated":"true"}],"comment":"Patch Set 1: Code-Review+1\n\nbar"
Pros:
Vote transition info is explicit. gerrit-trigger can just check this flag which may make it more reliable.
'updated' field indicates the specified label that was updated.
No duplicate info
Keeps event concise
Cons:
Breaks backwards compatibility with the gerrit-trigger pliugin and possibly other third party things.
I prefer option A. but wanted to get feedback just to see if there were strong opinions either way. I'm also open to other suggestions as well.