From 96c03199dddf36cbd0e2ad4089be535d73b26adc Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:30:23 +0200 Subject: Add "imported from Google Code" to imported issues. --- lib/gitlab/google_code_import/importer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index b5e82563ff1..5c7ac7fc4b7 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -340,7 +340,7 @@ module Gitlab def format_issue_body(author, date, content, attachments) body = [] - body << "*By #{author} on #{date}*" + body << "*By #{author} on #{date} (imported from Google Code)*" body << "---" if content.blank? -- cgit v1.2.1 From c242ca9a177c0a101e2a02541830ffe56a1ae23e Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:31:15 +0200 Subject: Get imported links to render correctly by not escaping all special chars. --- lib/gitlab/google_code_import/importer.rb | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 5c7ac7fc4b7..3916e51d0ab 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -207,21 +207,19 @@ module Gitlab end def escape_for_markdown(s) - s = s.gsub("*", "\\*") - s = s.gsub("#", "\\#") + # No headings and lists + s = s.gsub(/^#/, "\\#") + s = s.gsub(/^-/, "\\-") + + # No inline code s = s.gsub("`", "\\`") - s = s.gsub(":", "\\:") - s = s.gsub("-", "\\-") - s = s.gsub("+", "\\+") - s = s.gsub("_", "\\_") - s = s.gsub("(", "\\(") - s = s.gsub(")", "\\)") - s = s.gsub("[", "\\[") - s = s.gsub("]", "\\]") - s = s.gsub("<", "\\<") - s = s.gsub(">", "\\>") + + # Carriage returns make me sad s = s.gsub("\r", "") + + # Markdown ignores single newlines, but we need them as
. s = s.gsub("\n", " \n") + s end -- cgit v1.2.1 From bc2dd5e772dea3ec78462441413842f9fe82165a Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:31:50 +0200 Subject: Import "Comment #10" as "Comment 10" to not incorrectly reference issue. --- lib/gitlab/google_code_import/importer.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 3916e51d0ab..caa57f557c0 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -203,7 +203,9 @@ module Gitlab end def linkify_issues(s) - s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2') + s = s.gsub(/([Ii]ssue) ([0-9]+)/, '\1 #\2') + s = s.gsub(/([Cc]omment) #([0-9]+)/, '\1 \2') + s end def escape_for_markdown(s) -- cgit v1.2.1 From 18f80c55600e485c87d23afccd82b4947e27ff17 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:32:29 +0200 Subject: Fix rendering of deleted blocking/blocked-on statuses. --- lib/gitlab/google_code_import/importer.rb | 34 ++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index caa57f557c0..532689bca6c 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -276,11 +276,18 @@ module Gitlab if raw_updates.has_key?("blockedOn") blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on| name, id = raw_blocked_on.split(":", 2) - if name == project.import_source - "##{id}" - else - "#{project.namespace.path}/#{name}##{id}" - end + + deleted = name.start_with?("-") + name = name[1..-1] if deleted + + text = + if name == project.import_source + "##{id}" + else + "#{project.namespace.path}/#{name}##{id}" + end + text = "~~#{text}~~" if deleted + text end updates << "*Blocked on: #{blocked_ons.join(", ")}*" end @@ -288,11 +295,18 @@ module Gitlab if raw_updates.has_key?("blocking") blockings = raw_updates["blocking"].map do |raw_blocked_on| name, id = raw_blocked_on.split(":", 2) - if name == project.import_source - "##{id}" - else - "#{project.namespace.path}/#{name}##{id}" - end + + deleted = name.start_with?("-") + name = name[1..-1] if deleted + + text = + if name == project.import_source + "##{id}" + else + "#{project.namespace.path}/#{name}##{id}" + end + text = "~~#{text}~~" if deleted + text end updates << "*Blocking: #{blockings.join(", ")}*" end -- cgit v1.2.1 From 1c30f775995378082942f4c7c8c2f7bdc11e48a9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 21 Apr 2015 10:32:48 +0200 Subject: Don't autolink masked imported email addresses. --- lib/gitlab/google_code_import/importer.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb index 532689bca6c..70bfe059776 100644 --- a/lib/gitlab/google_code_import/importer.rb +++ b/lib/gitlab/google_code_import/importer.rb @@ -30,7 +30,10 @@ module Gitlab def user_map @user_map ||= begin - user_map = Hash.new { |hash, user| Client.mask_email(user) } + user_map = Hash.new do |hash, user| + # Replace ... by \.\.\., so `johnsm...@gmail.com` isn't autolinked. + Client.mask_email(user).sub("...", "\\.\\.\\.") + end import_data = project.import_data.try(:data) stored_user_map = import_data["user_map"] if import_data -- cgit v1.2.1