Class: Gitlab::Import::MergeRequestCreator

Inherits:
Object
  • Object
show all
Includes:
DatabaseHelpers, MergeRequestHelpers
Defined in:
lib/gitlab/import/merge_request_creator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MergeRequestHelpers

#create_merge_request_without_hooks, #insert_or_replace_git_data

Methods included from DatabaseHelpers

#insert_and_return_id

Constructor Details

#initialize(project) ⇒ MergeRequestCreator

Returns a new instance of MergeRequestCreator.


21
22
23
# File 'lib/gitlab/import/merge_request_creator.rb', line 21

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.


19
20
21
# File 'lib/gitlab/import/merge_request_creator.rb', line 19

def project
  @project
end

Instance Method Details

#execute(attributes) ⇒ Object


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gitlab/import/merge_request_creator.rb', line 25

def execute(attributes)
  source_branch_sha = attributes.delete(:source_branch_sha)
  target_branch_sha = attributes.delete(:target_branch_sha)
  iid = attributes[:iid]

  merge_request, already_exists = create_merge_request_without_hooks(project, attributes, iid)

  if merge_request
    insert_or_replace_git_data(merge_request, source_branch_sha, target_branch_sha, already_exists)
  end

  merge_request
end