func handleMergeFailed(c *client.IrcClient, msg *GerritMessage) { reasons := strings.Split(msg.Reason, "\n") reason := reasons[0] str := fmt.Sprintf("[%s/%s] %s tried to cherry-pick %s, but the merge failed because: %s - %s", msg.Change.Project, msg.Change.Branch, msg.Submitter.Name, msg.Change.Subject, reason, msg.Change.Url) c.WriteMessage(gerritChannel, str) }
func handleChangeMerged(c *client.IrcClient, msg *GerritMessage) { // TODO: msg.Owner.Name != msg.PatchSet.Uploader.Name, note // separately since someone else updating a patch is // significant str := fmt.Sprintf("[%s/%s] %s authored by %s was cherry-picked by %s - %s", msg.Change.Project, msg.Change.Branch, msg.Change.Subject, msg.PatchSet.Uploader.Name, msg.Submitter.Name, msg.Change.Url) c.WriteMessage(gerritChannel, str) }
func handleCommentAdded(c *client.IrcClient, msg *GerritMessage) { reviewstring := "" for _, approval := range msg.Approvals { if len(reviewstring) > 0 { reviewstring += " " } if approval.Value < 0 { // dark red } else if approval.Value > 0 { // dark green } atype := approval.Type // newer Gerrit uses long form type strings // canonicalize them into something useful if approval.Type == "Code-Review" { atype = "C" } else if approval.Type == "Sanity-Review" { atype = "S" } else if approval.Type == "CRVW" { atype = "C" } else if approval.Type == "SRVW" { atype = "S" } else { panic("Unknown approval type " + atype) } // TODO: color wrap reviewstring += fmt.Sprintf("%s: %d", atype, approval.Value) } // TODO: handle color when we add it if msg.Author.Email == "*****@*****.**" && reviewstring == "S: 1" { // drop these, they're spammy } else { if len(msg.Approvals) > 0 { msg := fmt.Sprintf("[%s/%s] %s from %s reviewed by %s: %s - %s", msg.Change.Project, msg.Change.Branch, msg.Change.Subject, msg.PatchSet.Uploader.Name, msg.Author.Name, reviewstring, msg.Change.Url) c.WriteMessage(gerritChannel, msg) } else { msg := fmt.Sprintf("[%s/%s] %s from %s commented by %s - %s", msg.Change.Project, msg.Change.Branch, msg.Change.Subject, msg.PatchSet.Uploader.Name, msg.Author.Name, msg.Change.Url) c.WriteMessage(gerritChannel, msg) } } }
func handlePatchSetCreated(c *client.IrcClient, msg *GerritMessage) { if msg.PatchSet.Number == 1 { msg := fmt.Sprintf("[%s/%s] %s pushed by %s - %s", msg.Change.Project, msg.Change.Branch, msg.Change.Subject, msg.PatchSet.Uploader.Name, msg.Change.Url) c.WriteMessage(gerritChannel, msg) } else { // TODO: msg.Owner.Name != msg.PatchSet.Uploader.Name, note // separately since someone else updating a patch is // significant msg := fmt.Sprintf("[%s/%s] %s updated by %s - %s", msg.Change.Project, msg.Change.Branch, msg.Change.Subject, msg.PatchSet.Uploader.Name, msg.Change.Url) c.WriteMessage(gerritChannel, msg) } }