Class: Gitlab::GithubImport::Importer::PullRequestImporter

Inherits:
Object
  • Object
show all
Includes:
Import::MergeRequestHelpers, Import::UsernameMentionRewriter, Import::PlaceholderReferences::Pusher
Defined in:
lib/gitlab/github_import/importer/pull_request_importer.rb

Constant Summary

Constants included from Import::UsernameMentionRewriter

Import::UsernameMentionRewriter::MENTION_REGEX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Import::PlaceholderReferences::Pusher

#map_to_personal_namespace_owner?, #push_reference, #push_reference_with_composite_key, #push_references_by_ids, #user_mapping_enabled?

Methods included from Import::UsernameMentionRewriter

#update_username_mentions, #wrap_mentions_in_backticks

Methods included from Import::MergeRequestHelpers

#add_approval_system_note!, #create_approval!, #create_merge_request_metrics, #create_merge_request_without_hooks, #create_reviewer!, #insert_merge_request_reviewers, #insert_or_replace_git_data

Methods included from Import::DatabaseHelpers

#insert_and_return_id

Constructor Details

#initialize(pull_request, project, client) ⇒ PullRequestImporter

pull_request - An instance of

`Gitlab::GithubImport::Representation::PullRequest`.

project - An instance of Project client - An instance of Gitlab::GithubImport::Client



18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 18

def initialize(pull_request, project, client)
  @pull_request = pull_request
  @project = project
  @client = client
  @user_finder = GithubImport::UserFinder.new(project, client)
  @milestone_finder = MilestoneFinder.new(project)
  @issuable_finder =
    GithubImport::IssuableFinder.new(project, pull_request)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def client
  @client
end

#issuable_finderObject (readonly)

Returns the value of attribute issuable_finder.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def issuable_finder
  @issuable_finder
end

#milestone_finderObject (readonly)

Returns the value of attribute milestone_finder.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def milestone_finder
  @milestone_finder
end

#projectObject (readonly)

Returns the value of attribute project.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def project
  @project
end

#pull_requestObject (readonly)

Returns the value of attribute pull_request.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def pull_request
  @pull_request
end

#user_finderObject (readonly)

Returns the value of attribute user_finder.



11
12
13
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 11

def user_finder
  @user_finder
end

Instance Method Details

#executeObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/gitlab/github_import/importer/pull_request_importer.rb', line 28

def execute
  mr, already_exists = create_merge_request

  if mr
    issuable_finder.cache_database_id(mr.id)
    set_merge_request_assignees(mr)
    insert_git_data(mr, already_exists)

    push_reference(project, mr, :author_id, pull_request.author&.id)

    # we only import one PR assignee
    assignee = mr.merge_request_assignees.first
    push_reference(project, assignee, :user_id, pull_request.assignee&.id) if assignee
  end
end