--- a/bitbucket/converter.go Tue Dec 31 01:08:27 2019 -0600
+++ b/bitbucket/converter.go Tue Jan 14 01:08:46 2020 -0600
@@ -1,6 +1,8 @@
"hg.sr.ht/~grim/youtrack-import/youtrack"
@@ -33,11 +35,16 @@
func (a *Archive) convertIssue(bb Issue, userMap map[string]*youtrack.User) *youtrack.Issue {
if user, found := userMap[bb.Reporter.AccountID]; found {
+ if user, found := userMap[bb.Assignee.AccountID]; found { @@ -45,10 +52,15 @@
+ Subsystem: bb.Component, + Comments: []youtrack.Comment{}, // TODO: check if state is resovled then set the Resolved field to the
@@ -65,9 +77,73 @@
+ yt.Comments = a.convertComments(userMap, bb.ID) +func (a *Archive) convertComments(userMap map[string]*youtrack.User, id int) []youtrack.Comment { + comments := []youtrack.Comment{} + for _, comment := range a.Comments { + if comment.Issue != id { + var ytComment youtrack.Comment + if comment.Content == "" { + // if we don't have a content we need to build it from the log + for _, log := range a.Logs { + if log.Comment == comment.ID { + if user, found := userMap[log.User.AccountID]; found { + if log.Field == "content" { + content = "edited description" + ytComment = youtrack.Comment{ + Created: log.CreatedOn, + if user, found := userMap[comment.User.AccountID]; found { + ytComment = youtrack.Comment{ + Created: comment.CreatedOn, + Updated: comment.UpdatedOn, + comments = append(comments, ytComment) func (a *Archive) convert(usersMap *UsersMap) (*youtrack.Project, error) {
users, err := a.ExtractUsers(usersMap)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/youtrack/comments.go Tue Jan 14 01:08:46 2020 -0600
@@ -0,0 +1,20 @@
+func sortComments(comments []Comment) { + sort.Slice(comments, func(i, j int) bool { + return comments[i].Created.Before(comments[j].Created) --- a/youtrack/issue.go Tue Dec 31 01:08:27 2019 -0600
+++ b/youtrack/issue.go Tue Jan 14 01:08:46 2020 -0600
@@ -17,9 +17,13 @@
UpdatedBy string `yt:"updaterName"`
Resolved time.Time `yt:"resolved"`
Reporter string `yt:"reporter"`
- Voters []string `yt:"voterName"`
- Watchers []string `yt:"watcherName"`
- PermittedGroup string `yt:"permittedGroup"`
+ Voters []string `yt:"voterName"` + Watchers []string `yt:"watcherName"` + PermittedGroup string `yt:"permittedGroup"` Priority string `yt:"priority"`
@@ -34,16 +38,27 @@
x.AddField("numberInProject", fmt.Sprintf("%d", i.Number))
x.AddField("summary", i.Summary)
- x.AddField("created", fmt.Sprintf("%d", i.Created.Unix()))
x.AddField("reporterName", i.Reporter)
+ x.AddField("Assignee", i.Assignee) + x.AddField("Type", i.Type) + x.AddField("Priority", i.Priority) + x.AddField("State", i.State) + x.AddField("markdown", "true") + if !i.Created.IsZero() { + x.AddField("created", formatTimeString(i.Created)) x.AddField("description", i.Description)
- x.AddField("updated", fmt.Sprintf("%d", i.Updated.Unix()))
+ x.AddField("updated", formatTimeString(i.Updated)) @@ -66,8 +81,17 @@
x.AddField("permittedGroup", i.PermittedGroup)
+ x.AddField("Fix Versions", i.Version) + x.AddField("Subsystem", i.Subsystem) + sortComments(i.Comments) for _, c := range i.Comments {
- x.AddComment(c.Author, c.Text, c.Created, c.Updated)
+ x.AddComment(c.Author, c.Text, c.Created, c.Updated, c.Markdown) --- a/youtrack/xml.go Tue Dec 31 01:08:27 2019 -0600
+++ b/youtrack/xml.go Tue Jan 14 01:08:46 2020 -0600
@@ -14,17 +14,17 @@
- XMLName xml.Name `xml:"comment"`
- Author string `xml:"author,attr,omitempty"`
- Text string `xml:"text,attr,omitempty"`
- Created int64 `xml:"created,attr,omitempty"`
- Updated int64 `xml:"updated,attr,omitempty"`
+ Author string `xml:"author,attr,omitempty"` + Text string `xml:"text,attr,omitempty"` + Created int64 `xml:"created,attr,omitempty"` + Updated int64 `xml:"updated,attr,omitempty"` + Markdown bool `xml:"markdown,attr,omitempty"` XMLName xml.Name `xml:"issue"`
+ Comments []xmlComment `xml:"comment,omitempty"` func (x *xmlIssue) AddField(name, value string) {
@@ -35,12 +35,13 @@
x.Fields = append(x.Fields, xmlField{Name: name, Values: values})
-func (x *xmlIssue) AddComment(author, text string, created, updated time.Time) {
+func (x *xmlIssue) AddComment(author, text string, created, updated time.Time, markdown bool) {
- Created: created.Unix(),
- Updated: updated.Unix(),
+ Created: formatTime(created), + Updated: formatTime(updated), x.Comments = append(x.Comments, c)
@@ -54,7 +55,7 @@
type xmlImportReportItemError struct {
FieldName string `xml:"fieldName,attr"`
Value string `xml:"value,attr"`
- Message string `xml:",cdata"`
+ Message string `xml:",chardata"` type xmlImportReportItem struct {
@@ -95,7 +96,7 @@
XMLName xml.Name `xml:"error"`
- Message string `xml:",cdata"`
+ Message string `xml:",chardata"`