@@ -250,10 +250,14 @@ func (s service) ListTimeline(ctx context.Context, _ string, id uint64, opt *cha
change, _, err := s.cl.Changes.GetChangeDetail(fmt.Sprint(id), nil)
if err != nil {
return nil, err
}
comments, _, err := s.cl.Changes.ListChangeComments(fmt.Sprint(id))
if err != nil {
return nil, err
}
var timeline []interface{}
{
timeline = append(timeline, changes.Comment{
ID: 0,
User: s.gerritUser(change.Owner),
@@ -279,41 +283,39 @@ func (s service) ListTimeline(ctx context.Context, _ string, id uint64, opt *cha
}
label, body, ok := parseMessage(message.Message)
if !ok {
continue
}
var state changes.ReviewState
switch label {
default:
state = changes.Commented
case "Code-Review+2":
timeline = append(timeline, changes.Review{
ID: uint64(idx), // TODO: message.ID is not uint64; e.g., "bfba753d015916303152305cee7152ea7a112fe0".
User: s.gerritUser(message.Author),
CreatedAt: time.Time(message.Date),
State: changes.Approved,
Body: body,
Editable: false,
})
continue
state = changes.Approved
case "Code-Review-2":
timeline = append(timeline, changes.Review{
ID: uint64(idx), // TODO: message.ID is not uint64; e.g., "bfba753d015916303152305cee7152ea7a112fe0".
User: s.gerritUser(message.Author),
CreatedAt: time.Time(message.Date),
State: changes.ChangesRequested,
Body: body,
Editable: false,
})
continue
state = changes.ChangesRequested
}
if body == "" {
continue
var cs []changes.InlineComment
for file, comments := range *comments {
for _, c := range comments {
if time.Time(c.Updated).Equal(time.Time(message.Date)) {
cs = append(cs, changes.InlineComment{
File: file,
Line: c.Line,
Body: c.Message,
})
}
}
}
timeline = append(timeline, changes.Comment{
timeline = append(timeline, changes.Review{
ID: uint64(idx), // TODO: message.ID is not uint64; e.g., "bfba753d015916303152305cee7152ea7a112fe0".
User: s.gerritUser(message.Author),
CreatedAt: time.Time(message.Date),
State: state,
Body: body,
Editable: false,
Comments: cs,
})
}
return timeline, nil
}