Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/legacy_github_import/issuable_formatter.rb')
-rw-r--r--lib/gitlab/legacy_github_import/issuable_formatter.rb66
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/gitlab/legacy_github_import/issuable_formatter.rb b/lib/gitlab/legacy_github_import/issuable_formatter.rb
new file mode 100644
index 00000000000..de55382d3ad
--- /dev/null
+++ b/lib/gitlab/legacy_github_import/issuable_formatter.rb
@@ -0,0 +1,66 @@
+module Gitlab
+ module LegacyGithubImport
+ class IssuableFormatter < BaseFormatter
+ attr_writer :assignee_id, :author_id
+
+ def project_association
+ raise NotImplementedError
+ end
+
+ delegate :number, to: :raw_data
+
+ def find_condition
+ { iid: number }
+ end
+
+ private
+
+ def state
+ raw_data.state == 'closed' ? 'closed' : 'opened'
+ end
+
+ def assigned?
+ raw_data.assignee.present?
+ end
+
+ def author
+ @author ||= UserFormatter.new(client, raw_data.user)
+ end
+
+ def author_id
+ @author_id ||= author.gitlab_id || project.creator_id
+ end
+
+ def assignee
+ if assigned?
+ @assignee ||= UserFormatter.new(client, raw_data.assignee)
+ end
+ end
+
+ def assignee_id
+ return @assignee_id if defined?(@assignee_id)
+
+ @assignee_id = assignee.try(:gitlab_id)
+ end
+
+ def body
+ raw_data.body || ""
+ end
+
+ def description
+ if author.gitlab_id
+ body
+ else
+ formatter.author_line(author.login) + body
+ end
+ end
+
+ def milestone
+ if raw_data.milestone.present?
+ milestone = MilestoneFormatter.new(project, raw_data.milestone)
+ project.milestones.find_by(milestone.find_condition)
+ end
+ end
+ end
+ end
+end