grim/youtrack-import

Parents 21e09c165b0a
Children 0217a2b03777
Add a function to flatten Bitbucket users to youtrack logins so we can export issue voters. Fixes YI-17
--- a/bitbucket/converter.go Wed Jan 15 23:37:24 2020 -0600
+++ b/bitbucket/converter.go Wed Jan 15 23:39:15 2020 -0600
@@ -66,6 +66,8 @@
Comments: []*youtrack.Comment{},
}
+ yt.Voters = flattenAuthors(userMap, bb.Voters)
+
// map field values from bitbucket to youtrack
if replace, found := priorityMap[yt.Priority]; found {
yt.Priority = replace
--- a/bitbucket/types.go Wed Jan 15 23:37:24 2020 -0600
+++ b/bitbucket/types.go Wed Jan 15 23:39:15 2020 -0600
@@ -3,6 +3,8 @@
import (
"archive/zip"
"time"
+
+ "hg.sr.ht/~grim/youtrack-import/youtrack"
)
type Author struct {
@@ -14,6 +16,18 @@
return a.DisplayName
}
+func flattenAuthors(userMap map[string]*youtrack.User, authors []Author) []string {
+ flat := make([]string, len(authors))
+
+ for idx, account := range authors {
+ if user, found := userMap[account.AccountID]; found {
+ flat[idx] = user.Login
+ }
+ }
+
+ return flat
+}
+
type Issue struct {
Assignee Author `json:"assignee"`
Component string `json:"component"`