Class: Dependabot::PullRequestCreator::Gitlab

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/pull_request_creator/gitlab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source:, branch_name:, base_commit:, credentials:, files:, commit_message:, pr_description:, pr_name:, author_details:, labeler:, approvers:, assignees:, milestone:, target_project_id:) ⇒ Gitlab

Returns a new instance of Gitlab.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 76

def initialize(source:, branch_name:, base_commit:, credentials:,
               files:, commit_message:, pr_description:, pr_name:,
               author_details:, labeler:, approvers:, assignees:,
               milestone:, target_project_id:)
  @source            = source
  @branch_name       = branch_name
  @base_commit       = base_commit
  @credentials       = credentials
  @files             = files
  @commit_message    = commit_message
  @pr_description    = pr_description
  @pr_name           = pr_name
  @author_details    = author_details
  @labeler           = labeler
  @approvers         = approvers
  @assignees         = assignees
  @milestone         = milestone
  @target_project_id = target_project_id
end

Instance Attribute Details

#approversObject (readonly)

Returns the value of attribute approvers.



46
47
48
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 46

def approvers
  @approvers
end

#assigneesObject (readonly)

Returns the value of attribute assignees.



49
50
51
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 49

def assignees
  @assignees
end

#author_detailsObject (readonly)

Returns the value of attribute author_details.



40
41
42
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 40

def author_details
  @author_details
end

#base_commitObject (readonly)

Returns the value of attribute base_commit.



22
23
24
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 22

def base_commit
  @base_commit
end

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



19
20
21
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 19

def branch_name
  @branch_name
end

#commit_messageObject (readonly)

Returns the value of attribute commit_message.



37
38
39
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 37

def commit_message
  @commit_message
end

#credentialsObject (readonly)

Returns the value of attribute credentials.



25
26
27
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 25

def credentials
  @credentials
end

#filesObject (readonly)

Returns the value of attribute files.



28
29
30
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 28

def files
  @files
end

#labelerObject (readonly)

Returns the value of attribute labeler.



43
44
45
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 43

def labeler
  @labeler
end

#milestoneObject (readonly)

Returns the value of attribute milestone.



52
53
54
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 52

def milestone
  @milestone
end

#pr_descriptionObject (readonly)

Returns the value of attribute pr_description.



31
32
33
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 31

def pr_description
  @pr_description
end

#pr_nameObject (readonly)

Returns the value of attribute pr_name.



34
35
36
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 34

def pr_name
  @pr_name
end

#sourceObject (readonly)

Returns the value of attribute source.



16
17
18
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 16

def source
  @source
end

#target_project_idObject (readonly)

Returns the value of attribute target_project_id.



55
56
57
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 55

def target_project_id
  @target_project_id
end

Instance Method Details

#createObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/dependabot/pull_request_creator/gitlab.rb', line 97

def create
  return if branch_exists? && merge_request_exists?

  if branch_exists?
    create_commit unless commit_exists?
  else
    create_branch
    create_commit
  end

  labeler.create_default_labels_if_required
  merge_request = create_merge_request
  return unless merge_request

  annotate_merge_request(merge_request)

  merge_request
end