--- a/trac/tickets.go Tue Jul 28 01:07:24 2020 -0500
+++ b/trac/tickets.go Tue Jul 28 21:40:48 2020 -0500
@@ -92,8 +92,26 @@
// things, so we just use the same regex to figure out the extension for
attachmentRegex = regexp.MustCompile(`\.[A-Za-z0-9]+$`)
+ // trac comments that are replies specify usernames which we can't/don't + // want to put in our resulting comments. + commentReplyingRegex = regexp.MustCompile(`^(?:(?:\> )*Replying to (?:[^]]+)\]:\r\n)+`) +func (tc *ticketChange) cleanNewValue() string { + if tc.Field == "comment" { + if strings.Contains(convertString(tc.OldValue), ".") { + str := convertString(tc.NewValue) + loc := commentReplyingRegex.FindIndex([]byte(str)) + return tc.NewValue.String func (t *ticket) toYoutrack(users map[string]*youtrack.User, unknownUser string) (*youtrack.Issue, error) {
convertUsername := func(sqluser sql.NullString) string {
username := convertString(sqluser)
@@ -176,18 +194,7 @@
- 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:]
+ description = change.cleanNewValue() issue.UpdatedBy = convertUsername(change.Author)