dmitri.shuralyov.com/service/change/...

gerritapi: add support for abandon events

Display a closed event when a CL is abandoned, and the abandon reason
if one is provided.
dmitshur committed 2 weeks ago commit 430bf650e55ac72ff59edca212763c965095cd53
gerritapi/gerritapi.go
@@ -317,10 +317,27 @@ func (s service) ListTimeline(ctx context.Context, repo string, id uint64, opt *
 					State:     change.Commented,
 					Body:      body,
 					Editable:  false,
 					Comments:  cs,
 				})
+			case "gerrit:abandon":
+				timeline = append(timeline, change.TimelineItem{
+					Actor:     s.gerritUser(message.Author),
+					CreatedAt: message.Date.Time,
+					Payload:   change.ClosedEvent{},
+				})
+				if message.Message == "Abandoned" {
+					// An abandon reason wasn't provided.
+					break
+				}
+				timeline = append(timeline, change.Comment{
+					ID:        fmt.Sprint(idx), // TODO: message.ID is not uint64; e.g., "bfba753d015916303152305cee7152ea7a112fe0".
+					User:      s.gerritUser(message.Author),
+					CreatedAt: message.Date.Time,
+					Body:      strings.TrimPrefix(message.Message, "Abandoned\n\n"),
+					Editable:  false,
+				})
 			}
 			continue
 		}
 		labels, body, ok := parseMessage(message.Message)
 		if !ok {