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

issue_event_importer.rb « importer « github_import « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2068f789fec6a667619dd2ca459339799b59e171 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# frozen_string_literal: true

module Gitlab
  module GithubImport
    module Importer
      class IssueEventImporter
        attr_reader :issue_event, :project, :client

        SUPPORTED_EVENTS = %w[
          assigned
          closed
          cross-referenced
          demilestoned
          labeled
          merged
          milestoned
          renamed
          reopened
          review_request_removed
          review_requested
          unassigned
          unlabeled
        ].freeze

        EXTENDED_SUPPORTED_EVENTS = SUPPORTED_EVENTS + %w[
          commented
          reviewed
        ].freeze

        # issue_event - An instance of `Gitlab::GithubImport::Representation::IssueEvent`.
        # project - An instance of `Project`.
        # client - An instance of `Gitlab::GithubImport::Client`.
        def initialize(issue_event, project, client)
          @issue_event = issue_event
          @project = project
          @client = client
        end

        def execute
          importer = event_importer_class(issue_event)
          if importer
            importer.new(project, client).execute(issue_event)
          else
            Gitlab::GithubImport::Logger.debug(
              message: 'UNSUPPORTED_EVENT_TYPE',
              event_type: issue_event.event, event_github_id: issue_event.id
            )
          end
        end

        private

        def event_importer_class(issue_event)
          case issue_event.event
          when 'closed'
            Gitlab::GithubImport::Importer::Events::Closed
          when 'reopened'
            Gitlab::GithubImport::Importer::Events::Reopened
          when 'labeled', 'unlabeled'
            Gitlab::GithubImport::Importer::Events::ChangedLabel
          when 'renamed'
            Gitlab::GithubImport::Importer::Events::Renamed
          when 'milestoned', 'demilestoned'
            Gitlab::GithubImport::Importer::Events::ChangedMilestone
          when 'cross-referenced'
            Gitlab::GithubImport::Importer::Events::CrossReferenced
          when 'assigned', 'unassigned'
            Gitlab::GithubImport::Importer::Events::ChangedAssignee
          when 'review_requested', 'review_request_removed'
            Gitlab::GithubImport::Importer::Events::ChangedReviewer
          when 'merged'
            Gitlab::GithubImport::Importer::Events::Merged
          when 'commented'
            Gitlab::GithubImport::Importer::Events::Commented
          when 'reviewed'
            Gitlab::GithubImport::Importer::Events::Reviewed
          end
        end
      end
    end
  end
end