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/github_import/importer/events/changed_label.rb')
-rw-r--r--lib/gitlab/github_import/importer/events/changed_label.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/importer/events/changed_label.rb b/lib/gitlab/github_import/importer/events/changed_label.rb
new file mode 100644
index 00000000000..6c408158b02
--- /dev/null
+++ b/lib/gitlab/github_import/importer/events/changed_label.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module GithubImport
+ module Importer
+ module Events
+ class ChangedLabel
+ def initialize(project, user_id)
+ @project = project
+ @user_id = user_id
+ end
+
+ # issue_event - An instance of `Gitlab::GithubImport::Representation::IssueEvent`.
+ def execute(issue_event)
+ create_event(issue_event)
+ end
+
+ private
+
+ attr_reader :project, :user_id
+
+ def create_event(issue_event)
+ ResourceLabelEvent.create!(
+ issue_id: issue_event.issue_db_id,
+ user_id: user_id,
+ label_id: label_finder.id_for(issue_event.label_title),
+ action: action(issue_event.event),
+ created_at: issue_event.created_at
+ )
+ end
+
+ def label_finder
+ Gitlab::GithubImport::LabelFinder.new(project)
+ end
+
+ def action(event_type)
+ event_type == 'unlabeled' ? 'remove' : 'add'
+ end
+ end
+ end
+ end
+ end
+end