--- a/bitbucket/cmd.go Wed Jan 15 06:11:24 2020 -0600
+++ b/bitbucket/cmd.go Wed Jan 15 06:35:33 2020 -0600
@@ -22,7 +22,7 @@
- project, err := archive.convert(usersMap)
+ project, err := archive.convert(g.ProjectID, usersMap) --- a/bitbucket/converter.go Wed Jan 15 06:11:24 2020 -0600
+++ b/bitbucket/converter.go Wed Jan 15 06:35:33 2020 -0600
@@ -34,7 +34,7 @@
-func (a *Archive) convertIssue(bb Issue, userMap map[string]*youtrack.User) *youtrack.Issue {
+func (a *Archive) convertIssue(projectID string, bb Issue, userMap map[string]*youtrack.User) *youtrack.Issue { if user, found := userMap[bb.Reporter.AccountID]; found {
@@ -48,7 +48,7 @@
- Description: replaceKeywords(userMap, bb.Content),
+ Description: replaceKeywords(userMap, projectID, bb.Content), @@ -80,13 +80,13 @@
// add the comments and attachments
- yt.Comments = a.convertComments(userMap, bb.ID)
+ yt.Comments = a.convertComments(projectID, userMap, bb.ID) yt.Attachments = a.convertAttachments(userMap, bb)
-func (a *Archive) convertComments(userMap map[string]*youtrack.User, id int) []*youtrack.Comment {
+func (a *Archive) convertComments(projectID string, userMap map[string]*youtrack.User, id int) []*youtrack.Comment { comments := []*youtrack.Comment{}
for _, comment := range a.Comments {
@@ -134,7 +134,7 @@
ytComment = &youtrack.Comment{
- Text: replaceKeywords(userMap, comment.Content),
+ Text: replaceKeywords(userMap, projectID, comment.Content), Created: comment.CreatedOn,
Updated: comment.UpdatedOn,
@@ -175,7 +175,7 @@
-func (a *Archive) convert(usersMap *UsersMap) (*youtrack.Project, error) {
+func (a *Archive) convert(projectID string, usersMap *UsersMap) (*youtrack.Project, error) { users, err := a.ExtractUsers(usersMap)
@@ -204,7 +204,7 @@
// convert all of the issues
issues := make([]*youtrack.Issue, len(a.Issues))
for i := 0; i < len(a.Issues); i++ {
- issues[i] = a.convertIssue(a.Issues[i], users)
+ issues[i] = a.convertIssue(projectID, a.Issues[i], users) project := &youtrack.Project{
--- a/bitbucket/keywords.go Wed Jan 15 06:11:24 2020 -0600
+++ b/bitbucket/keywords.go Wed Jan 15 06:35:33 2020 -0600
@@ -9,6 +9,7 @@
mentionRegex = regexp.MustCompile(`@\{(.+?)\}`)
+ issueRegex = regexp.MustCompile(`#(\d+)`) func replaceMentions(m map[string]*youtrack.User, message string) string {
@@ -27,10 +28,25 @@
-func replaceKeywords(m map[string]*youtrack.User, message string) string {
+func replaceIssues(projectID, message string) string { + matches := issueRegex.FindAllStringSubmatch(message, -1) + for _, match := range matches { + output = strings.Replace(output, old, projectID+"-"+id, 1) +func replaceKeywords(m map[string]*youtrack.User, projectID string, message string) string { output = replaceMentions(m, output)
+ output = replaceIssues(projectID, output)