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')
-rw-r--r--lib/gitlab/github_import/importer/events/base_importer.rb7
-rw-r--r--lib/gitlab/github_import/importer/events/commented.rb27
-rw-r--r--lib/gitlab/github_import/importer/events/merged.rb13
-rw-r--r--lib/gitlab/github_import/importer/events/reviewed.rb26
4 files changed, 72 insertions, 1 deletions
diff --git a/lib/gitlab/github_import/importer/events/base_importer.rb b/lib/gitlab/github_import/importer/events/base_importer.rb
index 8218acf2bfb..1ebafec5afc 100644
--- a/lib/gitlab/github_import/importer/events/base_importer.rb
+++ b/lib/gitlab/github_import/importer/events/base_importer.rb
@@ -10,6 +10,7 @@ module Gitlab
# client - An instance of `Gitlab::GithubImport::Client`.
def initialize(project, client)
@project = project
+ @client = client
@user_finder = UserFinder.new(project, client)
end
@@ -20,7 +21,7 @@ module Gitlab
private
- attr_reader :project, :user_finder
+ attr_reader :project, :user_finder, :client
def author_id(issue_event, author_key: :actor)
user_finder.author_id_for(issue_event, author_key: author_key).first
@@ -42,6 +43,10 @@ module Gitlab
belongs_to_key = merge_request_event?(issue_event) ? :merge_request_id : :issue_id
{ belongs_to_key => issuable_db_id(issue_event) }
end
+
+ def import_settings
+ @import_settings ||= Gitlab::GithubImport::Settings.new(project)
+ end
end
end
end
diff --git a/lib/gitlab/github_import/importer/events/commented.rb b/lib/gitlab/github_import/importer/events/commented.rb
new file mode 100644
index 00000000000..c9ebc31fa06
--- /dev/null
+++ b/lib/gitlab/github_import/importer/events/commented.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module GithubImport
+ module Importer
+ module Events
+ class Commented < BaseImporter
+ def execute(issue_event)
+ return true unless import_settings.extended_events?
+
+ note = Representation::Note.from_json_hash(
+ noteable_id: issue_event.issuable_id,
+ noteable_type: issue_event.issuable_type,
+ author: issue_event.actor&.to_hash,
+ note: issue_event.body,
+ created_at: issue_event.created_at,
+ updated_at: issue_event.updated_at,
+ note_id: issue_event.id
+ )
+
+ NoteImporter.new(note, project, client).execute
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/lib/gitlab/github_import/importer/events/merged.rb b/lib/gitlab/github_import/importer/events/merged.rb
index 6189fa8f429..702ea7f1fd5 100644
--- a/lib/gitlab/github_import/importer/events/merged.rb
+++ b/lib/gitlab/github_import/importer/events/merged.rb
@@ -6,6 +6,8 @@ module Gitlab
module Events
class Merged < BaseImporter
def execute(issue_event)
+ create_note(issue_event) if import_settings.extended_events?
+
create_event(issue_event)
create_state_event(issue_event)
end
@@ -37,6 +39,17 @@ module Gitlab
ResourceStateEvent.create!(attrs)
end
+
+ def create_note(issue_event)
+ pull_request = Representation::PullRequest.from_json_hash({
+ merged_by: issue_event.actor&.to_hash,
+ merged_at: issue_event.created_at,
+ iid: issue_event.issuable_id,
+ state: :closed
+ })
+
+ PullRequests::MergedByImporter.new(pull_request, project, client).execute
+ end
end
end
end
diff --git a/lib/gitlab/github_import/importer/events/reviewed.rb b/lib/gitlab/github_import/importer/events/reviewed.rb
new file mode 100644
index 00000000000..1c0e8a9e6e8
--- /dev/null
+++ b/lib/gitlab/github_import/importer/events/reviewed.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module GithubImport
+ module Importer
+ module Events
+ class Reviewed < BaseImporter
+ def execute(issue_event)
+ return true unless import_settings.extended_events?
+
+ review = Representation::PullRequestReview.new(
+ merge_request_iid: issue_event.issuable_id,
+ author: issue_event.actor&.to_hash,
+ note: issue_event.body.to_s,
+ review_type: issue_event.state.upcase, # On timeline API, the state is in lower case
+ submitted_at: issue_event.submitted_at,
+ review_id: issue_event.id
+ )
+
+ PullRequests::ReviewImporter.new(review, project, client).execute({ add_reviewer: false })
+ end
+ end
+ end
+ end
+ end
+end