fix(clbot): Use change *owner* and not *uploader*

In autosubmit cases that require rebases, the change *uploader* might
be clbot which would cause besadii to use clbot as the owner.

This is incorrect, but luckily the change-merged event has an actual
owner field instead.

Change-Id: Ia35b52085f94628e61eb358807b3b85565521b60
This commit is contained in:
Vincent Ambo 2021-12-10 16:19:53 +03:00 committed by clbot
parent bc3d35f3d0
commit 2fc64dc277

View file

@ -156,11 +156,11 @@ func runIRC(ctx context.Context, ircCfg irc.ClientConfig, sendMsg <-chan string)
} }
} }
func username(p gerritevents.PatchSet) string { func username(a gerritevents.Account) string {
options := []string{ options := []string{
p.Uploader.Username, a.Username,
p.Uploader.Name, a.Name,
p.Uploader.Email, a.Email,
} }
for _, opt := range options { for _, opt := range options {
if opt != "" { if opt != "" {
@ -243,13 +243,13 @@ func main() {
if e.Change.Project != *notifyRepo || !notifyBranches[e.Change.Branch] || e.PatchSet.Number != 1 { if e.Change.Project != *notifyRepo || !notifyBranches[e.Change.Branch] || e.PatchSet.Number != 1 {
continue continue
} }
user := username(e.PatchSet) user := username(e.PatchSet.Uploader)
parsedMsg = nopingAll(user, fmt.Sprintf("CL/%d proposed by %s - %s - %s", e.Change.Number, user, e.Change.Subject, patchSetURL(e.Change, e.PatchSet))) parsedMsg = nopingAll(user, fmt.Sprintf("CL/%d proposed by %s - %s - %s", e.Change.Number, user, e.Change.Subject, patchSetURL(e.Change, e.PatchSet)))
case *gerritevents.ChangeMerged: case *gerritevents.ChangeMerged:
if e.Change.Project != *notifyRepo || !notifyBranches[e.Change.Branch] { if e.Change.Project != *notifyRepo || !notifyBranches[e.Change.Branch] {
continue continue
} }
owner := username(e.PatchSet) owner := username(e.Change.Owner)
submitter := e.Submitter.Username submitter := e.Submitter.Username
url := patchSetURL(e.Change, e.PatchSet) url := patchSetURL(e.Change, e.PatchSet)