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

gerritapi, maintner: Include CL description comment.

Make it more consistent across the services.
dmitshur committed 6 years ago commit e0b1851bb90c56a9e6ab2adcdd90f5143212de3f
Collapse all
gerritapi/gerritapi.go
@@ -254,19 +254,17 @@ func (s service) ListTimeline(ctx context.Context, _ string, id uint64, opt *cha
	comments, _, err := s.cl.Changes.ListChangeComments(fmt.Sprint(id))
	if err != nil {
		return nil, err
	}
	var timeline []interface{}
	{
		timeline = append(timeline, change.Comment{
			ID:        "0",
			User:      s.gerritUser(chg.Owner),
			CreatedAt: time.Time(chg.Created),
			Body:      "", // THINK: Include commit message or no?
			Editable:  false,
		})
	}
	timeline = append(timeline, change.Comment{ // CL description.
		ID:        "0",
		User:      s.gerritUser(chg.Owner),
		CreatedAt: time.Time(chg.Created),
		Body:      "", // THINK: Include commit message or no?
		Editable:  false,
	})
	for idx, message := range chg.Messages {
		if strings.HasPrefix(message.Tag, "autogenerated:") {
			switch message.Tag[len("autogenerated:"):] {
			case "gerrit:merged":
				timeline = append(timeline, change.TimelineItem{
maintner/maintner.go
@@ -124,10 +124,16 @@ func (s service) ListTimeline(_ context.Context, repo string, id uint64, opt *ch
	cl := project.CL(int32(id))
	if cl == nil || cl.Private || cl.Status == "" {
		return nil, os.ErrNotExist
	}
	var timeline []interface{}
	timeline = append(timeline, change.Comment{ // CL description.
		ID:        "0",
		User:      gerritUser(cl.Commit.Author),
		CreatedAt: cl.Created,
		Body:      "", // THINK: Include commit message or no?
	})
	for _, m := range cl.Messages {
		label, body, ok := parseMessage(m.Message)
		if !ok {
			timeline = append(timeline, change.Comment{
				User:      gerritUser(m.Author),