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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 12:07:45 +0300
commitb11f7057d067885619ee3e513751f180b2e8ad85 (patch)
treedfb3077ea8716ed217f5ce4324be4e25a450c599 /lib/gitlab/jira_import
parente50050a8756a20b6aa118edbad3369674e4c63ba (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/jira_import')
-rw-r--r--lib/gitlab/jira_import/labels_importer.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/lib/gitlab/jira_import/labels_importer.rb b/lib/gitlab/jira_import/labels_importer.rb
new file mode 100644
index 00000000000..142a2da5be9
--- /dev/null
+++ b/lib/gitlab/jira_import/labels_importer.rb
@@ -0,0 +1,42 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module JiraImport
+ class LabelsImporter < BaseImporter
+ attr_reader :job_waiter
+
+ def initialize(project)
+ super
+ @job_waiter = JobWaiter.new
+ end
+
+ def execute
+ create_import_label(project)
+ import_jira_labels
+ end
+
+ private
+
+ def create_import_label(project)
+ label = Labels::CreateService.new(build_label_attrs(project)).execute(project: project)
+ raise Projects::ImportService::Error, _('Failed to create import label for jira import.') unless label
+
+ JiraImport.cache_import_label_id(project.id, label.id)
+ end
+
+ def build_label_attrs(project)
+ import_start_time = project&.import_state&.last_update_started_at || Time.now
+ title = "jira-import-#{import_start_time.strftime('%Y-%m-%d-%H-%M-%S')}"
+ description = "Label for issues that were imported from jira on #{import_start_time.strftime('%Y-%m-%d %H:%M:%S')}"
+ color = "#{Label.color_for(title)}"
+
+ { title: title, description: description, color: color }
+ end
+
+ def import_jira_labels
+ # todo: import jira labels, see https://gitlab.com/gitlab-org/gitlab/-/issues/212651
+ job_waiter
+ end
+ end
+ end
+end