--- a/trac/tickets.go Mon Jul 27 22:58:56 2020 -0500
+++ b/trac/tickets.go Tue Jul 28 01:07:24 2020 -0500
@@ -138,40 +138,57 @@
// as we iterate the comments and then only "commit" the change when it has
// a new author/timestamp or when we're looking at the last one.
var comment *youtrack.Comment
for _, change := range t.Changes {
- newComment := &youtrack.Comment{
- Author: convertUsername(change.Author),
- Created: convertTime(change.Time),
- Updated: convertTime(change.Time),
+ if comment != nil && convertTime(change.Time) != comment.Created { + // Add the description at the end to make sure all the field changes + // are always listed before it. + if comment.Text != "" { + comment.Text += description - // There's some oddness in our trac where we have a few changes where
- // the author is null, so if it's empty string, set it to the
- if newComment.Author == "" {
- newComment.Author = unknownUser
+ // our changes were loaded from the database ordered by timestamp, + // so if we hit a new time stamp, we're in a new change. + issue.Comments = append(issue.Comments, comment)
- if comment.Author != newComment.Author || comment.Created != newComment.Created {
- issue.Comments = append(issue.Comments, comment)
+ comment = &youtrack.Comment{ + Author: convertUsername(change.Author), + Created: convertTime(change.Time), + Updated: convertTime(change.Time), + // There's some oddness in our trac where we have a few changes where + // the author is null, so if it's empty string, set it to the + if comment.Author == "" { + comment.Author = unknownUser - // if the comment already has text, add a newline to help make the
- // actual comment text stand out.
- if comment.Text != "" {
+ description = convertString(change.NewValue) + // if the comment is a reply, we strip off the first line as there's + // now way to replicated this properly in youtrack. Note trac uses + // `\r` like a bunch of weirdos... + if strings.Contains(convertString(change.OldValue), ".") { + newLine := strings.Index(description, "\r") + description = description[newLine+1:] - text += convertString(change.NewValue)
issue.UpdatedBy = convertUsername(change.Author)
text = "description: modified\n"
@@ -184,17 +201,42 @@
+ oldValue := convertString(change.OldValue) + newValue := convertString(change.NewValue) + fieldName := change.Field
- convertString(change.OldValue),
- convertString(change.NewValue),
+ // Add the description at the end to make sure all the field changes are + // always listed before it. + if comment.Text != "" { + comment.Text += description issue.Comments = append(issue.Comments, comment)