Commit c903f23f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Split complex methods in GoogleCodeImport::Importer

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ea6a78ef
...@@ -76,18 +76,7 @@ module Gitlab ...@@ -76,18 +76,7 @@ module Gitlab
attachments = format_attachments(raw_issue["id"], 0, issue_comment["attachments"]) attachments = format_attachments(raw_issue["id"], 0, issue_comment["attachments"])
body = format_issue_body(author, date, content, attachments) body = format_issue_body(author, date, content, attachments)
labels = import_issue_labels(raw_issue)
labels = []
raw_issue["labels"].each do |label|
name = nice_label_name(label)
labels << name
unless @known_labels.include?(name)
create_label(name)
@known_labels << name
end
end
labels << nice_status_name(raw_issue["status"])
assignee_id = nil assignee_id = nil
if raw_issue.has_key?("owner") if raw_issue.has_key?("owner")
...@@ -110,6 +99,7 @@ module Gitlab ...@@ -110,6 +99,7 @@ module Gitlab
assignee_id: assignee_id, assignee_id: assignee_id,
state: raw_issue["state"] == "closed" ? "closed" : "opened" state: raw_issue["state"] == "closed" ? "closed" : "opened"
) )
issue.add_labels_by_names(labels) issue.add_labels_by_names(labels)
if issue.iid != raw_issue["id"] if issue.iid != raw_issue["id"]
...@@ -120,6 +110,23 @@ module Gitlab ...@@ -120,6 +110,23 @@ module Gitlab
end end
end end
def import_issue_labels(raw_issue)
labels = []
raw_issue["labels"].each do |label|
name = nice_label_name(label)
labels << name
unless @known_labels.include?(name)
create_label(name)
@known_labels << name
end
end
labels << nice_status_name(raw_issue["status"])
labels
end
def import_issue_comments(issue, comments) def import_issue_comments(issue, comments)
Note.transaction do Note.transaction do
while raw_comment = comments.shift while raw_comment = comments.shift
...@@ -278,25 +285,24 @@ module Gitlab ...@@ -278,25 +285,24 @@ module Gitlab
if raw_updates.has_key?("blockedOn") if raw_updates.has_key?("blockedOn")
blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on| blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on|
name, id = raw_blocked_on.split(":", 2) format_blocking_updates(raw_blocked_on)
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 end
updates << "*Blocked on: #{blocked_ons.join(", ")}*" updates << "*Blocked on: #{blocked_ons.join(", ")}*"
end end
if raw_updates.has_key?("blocking") if raw_updates.has_key?("blocking")
blockings = raw_updates["blocking"].map do |raw_blocked_on| blockings = raw_updates["blocking"].map do |raw_blocked_on|
format_blocking_updates(raw_blocked_on)
end
updates << "*Blocking: #{blockings.join(", ")}*"
end
updates
end
def format_blocking_updates(raw_blocked_on)
name, id = raw_blocked_on.split(":", 2) name, id = raw_blocked_on.split(":", 2)
deleted = name.start_with?("-") deleted = name.start_with?("-")
...@@ -311,11 +317,6 @@ module Gitlab ...@@ -311,11 +317,6 @@ module Gitlab
text = "~~#{text}~~" if deleted text = "~~#{text}~~" if deleted
text text
end end
updates << "*Blocking: #{blockings.join(", ")}*"
end
updates
end
def format_attachments(issue_id, comment_id, raw_attachments) def format_attachments(issue_id, comment_id, raw_attachments)
return [] unless raw_attachments return [] unless raw_attachments
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment