@@ -264,20 +264,24 @@ func (s service) ListTimeline(ctx context.Context, repo string, id uint64, opt * if resp != nil && resp.StatusCode == http.StatusNotFound { return nil, os.ErrNotExist } return nil, err } commit, _, err := s.cl.Changes.GetCommit(fmt.Sprintf("%s~%d", project, id), "current", nil) if err != nil { return nil, err } comments, _, err := s.cl.Changes.ListChangeComments(fmt.Sprintf("%s~%d", project, id)) if err != nil { return nil, err } var timeline []interface{} timeline = append(timeline, change.Comment{ // CL description. ID: "0", User: s.gerritUser(chg.Owner), CreatedAt: chg.Created.Time, Body: "", // THINK: Include commit message or no? Body: commitMessageBody(commit.Message), Editable: false, }) for idx, message := range chg.Messages { if strings.HasPrefix(message.Tag, "autogenerated:") { switch message.Tag[len("autogenerated:"):] { @@ -518,10 +522,25 @@ func (s service) gerritUser(user gerrit.AccountInfo) users.User { //Email: user.Email, AvatarURL: avatarURL, } } // commitMessageBody returns the body from a commit message. // It trims off the subject from start, and headers from end. func commitMessageBody(s string) string { i := strings.Index(s, "\n\n") if i == -1 { return "" } i += len("\n\n") j := strings.LastIndex(s, "\n\n") if i > j { return s[i:] } return s[i:j] } func project(repo string) string { i := strings.IndexByte(repo, '/') if i == -1 { return "" }