--- a/bitbucket/converter.go Sun Jan 19 14:03:22 2020 -0600
+++ b/bitbucket/converter.go Sun Jan 19 14:31:08 2020 -0600
@@ -2,6 +2,7 @@
"hg.sr.ht/~grim/youtrack-import/youtrack"
@@ -33,8 +34,22 @@
"blocker": "Show-stopper",
+ newlineRegex = regexp.MustCompile(`\r\n`) +func cleanupMessage(m map[string]*youtrack.User, nIssues int, projectID, repository, message string) string { + // replace \r\n with \n + output = newlineRegex.ReplaceAllString(output, "\n") + output = replaceKeywords(m, nIssues, projectID, repository, output) + output = replaceCreole(m, output) 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 +64,7 @@
- Description: replaceKeywords(userMap, nIssues, projectID, repository, bb.Content),
+ Description: cleanupMessage(userMap, nIssues, projectID, repository, bb.Content), @@ -134,7 +149,7 @@
ytComment := &youtrack.Comment{
- Text: replaceKeywords(userMap, nIssues, projectID, repository, comment.Content),
+ Text: cleanupMessage(userMap, nIssues, projectID, repository, comment.Content), Created: comment.CreatedOn,
Updated: comment.UpdatedOn,
--- a/bitbucket/creole.go Sun Jan 19 14:03:22 2020 -0600
+++ b/bitbucket/creole.go Sun Jan 19 14:31:08 2020 -0600
@@ -1,54 +1,22 @@
"hg.sr.ht/~grim/youtrack-import/youtrack"
creoleLinkRegex = regexp.MustCompile(`\[\[(.+?)\|(.+?)\]\]`)
- creoleCodeRegex = regexp.MustCompile("```" + `\r\n#!((.*?)\r\n)`)
+ creoleCodeRegex = regexp.MustCompile("```" + `\n#!((.*?)\n)`) func replaceCreoleLinks(message string) string {
- matches := creoleLinkRegex.FindAllStringSubmatch(message, -1)
- for _, match := range matches {
- replacement := fmt.Sprintf("[%s](%s)", text, uri)
- output = strings.Replace(output, old, replacement, 1)
+ return creoleLinkRegex.ReplaceAllString(message, "[$2]($1)") func replaceCreoleCode(message string) string {
- matches := creoleCodeRegex.FindAllStringSubmatch(message, -1)
- for _, match := range matches {
- replacement := fmt.Sprintf("```%s\n", lang)
- output = strings.Replace(output, old, replacement, 1)
- fmt.Printf("output: %q\n", output)
+ return creoleCodeRegex.ReplaceAllString(message, "```$2\n") func replaceCreole(m map[string]*youtrack.User, message string) string {
--- a/bitbucket/keywords.go Sun Jan 19 14:03:22 2020 -0600
+++ b/bitbucket/keywords.go Sun Jan 19 14:31:08 2020 -0600
@@ -107,7 +107,5 @@
output = replaceChangeSets(repository, output)
output = replaceCommitHashes(repository, output)
- output = replaceCreole(m, output)