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

gerritapi: skip empty comment that only sets labels

Comments are meant for entries that contain non-empty content. Some
entries contain, e.g., a Run-TryBot+1 vote, but otherwise empty body.
We may want to visualize such timeline entries in a more lightweight,
event-like manner. For now, just skip them instead of displaying
empty comments.
dmitshur committed 1 year ago commit e8a331073e94e21148d9babdc9751f8b8d252aba
gerritapi/gerritapi.go
@@ -365,15 +365,20 @@ func (s service) ListTimeline(ctx context.Context, repo string, id uint64, opt *
 						Body: c.Message,
 					})
 				}
 			}
 		}
+		reviewState := reviewState(labels)
+		if body == "" && len(cs) == 0 && reviewState == change.Commented && labels != "" {
+			// Skip an empty comment that, e.g., just sets a Run-TryBot+1 label.
+			continue
+		}
 		timeline = append(timeline, change.Review{
 			ID:        fmt.Sprint(idx), // TODO: message.ID is not uint64; e.g., "bfba753d015916303152305cee7152ea7a112fe0".
 			User:      s.gerritUser(message.Author),
 			CreatedAt: message.Date.Time,
-			State:     reviewState(labels),
+			State:     reviewState,
 			Body:      body,
 			Editable:  false,
 			Comments:  cs,
 		})
 	}