about summary refs log tree commit diff
path: root/fun/clbot/clbot.go
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-12-10T11·59+0300
committerVincent Ambo <mail@tazj.in>2021-12-10T12·34+0300
commit7e3308df64029380e4f26f1aa437afcd3097518b (patch)
treea37d45d62394b1475bfb1e7ffe0649e008016087 /fun/clbot/clbot.go
parentfc14c21bb91cb59956367dac17e59494911189fd (diff)
feat(fun/clbot): Add distinct messages for auto-submitted CLs r/3179
Detects autosubmitted CLs (other people's CLs submitted by clbot) and
modifies the text submitted to IRC accordingly.

If a CL is autosubmitted, we opt to highlight its author rather than
invoking noping.

Change-Id: Ibc21b7eeb2f0f2087097404baef6976384d68b09
Diffstat (limited to 'fun/clbot/clbot.go')
-rw-r--r--fun/clbot/clbot.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/fun/clbot/clbot.go b/fun/clbot/clbot.go
index a97d28e0f73d..317d99e22f05 100644
--- a/fun/clbot/clbot.go
+++ b/fun/clbot/clbot.go
@@ -249,8 +249,19 @@ func main() {
 				if e.Change.Project != *notifyRepo || !notifyBranches[e.Change.Branch] {
 					continue
 				}
-				user := username(e.PatchSet)
-				parsedMsg = nopingAll(user, fmt.Sprintf("CL/%d applied by %s - %s - %s", e.Change.Number, user, e.Change.Subject, patchSetURL(e.Change, e.PatchSet)))
+				owner := username(e.PatchSet)
+				submitter := e.Submitter.Username
+				url := patchSetURL(e.Change, e.PatchSet)
+
+				if submitter != owner && submitter == "clbot" {
+					// Ping CL author on IRC for autosubmitted messages, as this
+					// is not necessarily an action they would otherwise notice.
+					// We avoid pinging only for actions triggered by the same
+					// user.
+					parsedMsg = fmt.Sprintf("CL/%d by %s autosubmitted - %s - %s", e.Change.Number, owner, e.Change.Subject, url)
+				} else {
+					parsedMsg = nopingAll(owner, fmt.Sprintf("CL/%d applied by %s - %s - %s", e.Change.Number, owner, e.Change.Subject, url))
+				}
 			}
 			if parsedMsg != "" {
 				sendMsgChan <- parsedMsg