--- a/bitbucket/converter.go Thu Jan 16 01:16:43 2020 -0600
+++ b/bitbucket/converter.go Thu Jan 16 02:32:47 2020 -0600
@@ -35,7 +35,7 @@
-func (a *Archive) convertIssue(projectID, repository string, bb Issue, userMap map[string]*youtrack.User) *youtrack.Issue {
+func (a *Archive) convertIssue(nIssues int, projectID, repository string, bb Issue, userMap map[string]*youtrack.User) *youtrack.Issue { if user, found := userMap[bb.Reporter.AccountID]; found {
@@ -49,7 +49,7 @@
- Description: replaceKeywords(userMap, projectID, repository, bb.Content),
+ Description: replaceKeywords(userMap, nIssues, projectID, repository, bb.Content), @@ -81,13 +81,13 @@
// add the comments and attachments
- yt.Comments = a.convertComments(projectID, repository, userMap, bb.ID)
+ yt.Comments = a.convertComments(nIssues, projectID, repository, userMap, bb.ID) yt.Attachments = a.convertAttachments(userMap, bb)
-func (a *Archive) convertComments(projectID, repository string, userMap map[string]*youtrack.User, id int) []*youtrack.Comment {
+func (a *Archive) convertComments(nIssues int, projectID, repository string, userMap map[string]*youtrack.User, id int) []*youtrack.Comment { comments := []*youtrack.Comment{}
for _, comment := range a.Comments {
@@ -124,7 +124,7 @@
ytComment := &youtrack.Comment{
- Text: replaceKeywords(userMap, projectID, repository, comment.Content),
+ Text: replaceKeywords(userMap, nIssues, projectID, repository, comment.Content), Created: comment.CreatedOn,
Updated: comment.UpdatedOn,
@@ -191,9 +191,10 @@
// convert all of the issues
- issues := make([]*youtrack.Issue, len(a.Issues))
- for i := 0; i < len(a.Issues); i++ {
- issues[i] = a.convertIssue(projectID, repository, a.Issues[i], users)
+ nIssues := len(a.Issues) + issues := make([]*youtrack.Issue, nIssues) + for i := 0; i < nIssues; i++ { + issues[i] = a.convertIssue(nIssues, projectID, repository, a.Issues[i], users) project := &youtrack.Project{
--- a/bitbucket/keywords.go Thu Jan 16 01:16:43 2020 -0600
+++ b/bitbucket/keywords.go Thu Jan 16 02:32:47 2020 -0600
@@ -3,6 +3,7 @@
"hg.sr.ht/~grim/youtrack-import/youtrack"
@@ -10,7 +11,7 @@
mentionRegex = regexp.MustCompile(`@\{(.+?)\}`)
- prIssueRegex = regexp.MustCompile(`((PR)\s+)?#(\d+)`)
+ prIssueRegex = regexp.MustCompile(`(([Pp][Rr])\s+)?(\\)?#(\d+)`) csetRegex = regexp.MustCompile(`→ <<cset (.+?)>>`)
@@ -30,20 +31,22 @@
-func replacePullRequestsIssues(repository, projectID, message string) string {
+func replacePullRequestsIssues(nIssues int, repository, projectID, message string) string { matches := prIssueRegex.FindAllStringSubmatch(message, -1)
for _, match := range matches {
+ nId, _ := strconv.Atoi(id) + if pr != "" || nId > nIssues { replacement = fmt.Sprintf(
- "[%s](https://bitbucket.org/%s/pull-requests/%s)",
+ "[PR #%s](https://bitbucket.org/%s/pull-requests/%s)", @@ -76,11 +79,11 @@
-func replaceKeywords(m map[string]*youtrack.User, projectID, repository, message string) string {
+func replaceKeywords(m map[string]*youtrack.User, nIssues int, projectID, repository, message string) string { output = replaceMentions(m, output)
- output = replacePullRequestsIssues(repository, projectID, output)
+ output = replacePullRequestsIssues(nIssues, repository, projectID, output) output = replaceChangeSets(repository, output)