Class: LabClient::MergeRequest

Inherits:
Klass show all
Includes:
ClassHelpers
Defined in:
lib/labclient/merge_requests/merge_request.rb

Overview

Inspect Helper rubocop:disable Metrics/ClassLength

Instance Attribute Summary

Attributes inherited from Klass

#client, #response

Attributes inherited from LabStruct

#response

Instance Method Summary collapse

Methods included from ClassHelpers

#has?, #keys, #raw

Methods inherited from Klass

#api_methods, #collect_project_id, #collect_release_id, #collect_repository_id, date_time_attrs, #format_time?, #group_name, #help, #initialize, #klass, #success?, #to_json, #update_self, user_attrs, #valid_group_project_levels, #verbose

Methods included from Docs

#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title

Methods included from CurlHelper

#curl

Methods inherited from LabStruct

#as_json, #client, #keys, #slice, #success?

Constructor Details

This class inherits a constructor from LabClient::Klass

Instance Method Details

#accept(query = {}) ⇒ Object



54
55
56
# File 'lib/labclient/merge_requests/merge_request.rb', line 54

def accept(query = {})
  client.merge_requests.accept(project_id, iid, query)
end

#add_spent_time(duration) ⇒ Object



70
71
72
# File 'lib/labclient/merge_requests/merge_request.rb', line 70

def add_spent_time(duration)
  client.merge_requests.add_spent_time(project_id, iid, duration)
end

#approvalsObject

Approvals



132
133
134
# File 'lib/labclient/merge_requests/merge_request.rb', line 132

def approvals
  client.approvals.merge_request.show(project_id, iid)
end

#approvals_rule_create(query = {}) ⇒ Object



144
145
146
# File 'lib/labclient/merge_requests/merge_request.rb', line 144

def approvals_rule_create(query = {})
  client.approvals.merge_request.create_rule(project_id, iid, query)
end

#approvals_rule_delete(approval_rule_id) ⇒ Object



152
153
154
# File 'lib/labclient/merge_requests/merge_request.rb', line 152

def approvals_rule_delete(approval_rule_id)
  client.approvals.merge_request.delete_rule(project_id, iid, approval_rule_id)
end

#approvals_rule_update(approval_rule_id, query = {}) ⇒ Object



148
149
150
# File 'lib/labclient/merge_requests/merge_request.rb', line 148

def approvals_rule_update(approval_rule_id, query = {})
  client.approvals.merge_request.update_rule(project_id, iid, approval_rule_id, query)
end

#approvals_rulesObject



140
141
142
# File 'lib/labclient/merge_requests/merge_request.rb', line 140

def approvals_rules
  client.approvals.merge_request.rules(project_id, iid)
end

#approvals_update(approvals_required) ⇒ Object



136
137
138
# File 'lib/labclient/merge_requests/merge_request.rb', line 136

def approvals_update(approvals_required)
  client.approvals.merge_request.update(project_id, iid, approvals_required)
end

#approve(query = {}) ⇒ Object



156
157
158
# File 'lib/labclient/merge_requests/merge_request.rb', line 156

def approve(query = {})
  client.approvals.merge_request.approve(project_id, iid, query)
end

#assigneesObject



22
23
24
# File 'lib/labclient/merge_requests/merge_request.rb', line 22

def assignees
  @table[:assignees].map { |x| User.new(x, response, client) } if has? :assignees
end

#cancel_auto_mergeObject



62
63
64
# File 'lib/labclient/merge_requests/merge_request.rb', line 62

def cancel_auto_merge
  client.merge_requests.cancel_auto_merge(project_id, iid)
end

#changesObject



30
31
32
# File 'lib/labclient/merge_requests/merge_request.rb', line 30

def changes
  client.merge_requests.changes(project_id, iid)
end

#closes_issuesObject



86
87
88
# File 'lib/labclient/merge_requests/merge_request.rb', line 86

def closes_issues
  client.merge_requests.closes_issues(project_id, iid)
end

#commitsObject



34
35
36
# File 'lib/labclient/merge_requests/merge_request.rb', line 34

def commits
  client.merge_requests.commits(project_id, iid)
end

#create_pipelineObject



42
43
44
# File 'lib/labclient/merge_requests/merge_request.rb', line 42

def create_pipeline
  client.merge_requests.create_pipeline(project_id, iid)
end

#deleteObject



50
51
52
# File 'lib/labclient/merge_requests/merge_request.rb', line 50

def delete
  client.merge_requests.delete(project_id, iid)
end

#diff_versionsObject



114
115
116
# File 'lib/labclient/merge_requests/merge_request.rb', line 114

def diff_versions
  client.merge_requests.diff_versions(project_id, iid)
end

#inspectObject

extend Docs



9
10
11
# File 'lib/labclient/merge_requests/merge_request.rb', line 9

def inspect
  "#<MergeRequest id: #{id}, title: #{title}, state: #{state}>"
end

#merge_refObject



58
59
60
# File 'lib/labclient/merge_requests/merge_request.rb', line 58

def merge_ref
  client.merge_requests.merge_ref(project_id, iid)
end

#note_create(query) ⇒ Object



102
103
104
# File 'lib/labclient/merge_requests/merge_request.rb', line 102

def note_create(query)
  client.notes.merge_requests.create(project_id, iid, query)
end

#notesObject



98
99
100
# File 'lib/labclient/merge_requests/merge_request.rb', line 98

def notes
  client.notes.merge_requests.list(project_id, iid)
end

#participantsObject



26
27
28
# File 'lib/labclient/merge_requests/merge_request.rb', line 26

def participants
  client.merge_requests.participants(project_id, iid)
end

#pipelinesObject



38
39
40
# File 'lib/labclient/merge_requests/merge_request.rb', line 38

def pipelines
  client.merge_requests.pipelines(project_id, iid)
end

#projectObject

Default to Source Project



119
120
121
# File 'lib/labclient/merge_requests/merge_request.rb', line 119

def project
  client.projects.show(source_project_id)
end

#rebase(skip_ci = false) ⇒ Object



66
67
68
# File 'lib/labclient/merge_requests/merge_request.rb', line 66

def rebase(skip_ci = false)
  client.merge_requests.rebase(project_id, iid, skip_ci)
end

#reloadObject

Reload



174
175
176
# File 'lib/labclient/merge_requests/merge_request.rb', line 174

def reload
  update_self client.merge_requests.show(project_id, iid)
end

#reset_spent_timeObject



82
83
84
# File 'lib/labclient/merge_requests/merge_request.rb', line 82

def reset_spent_time
  client.merge_requests.reset_spent_time(project_id, iid)
end

#reset_time_estimateObject



78
79
80
# File 'lib/labclient/merge_requests/merge_request.rb', line 78

def reset_time_estimate
  client.merge_requests.reset_time_estimate(project_id, iid)
end

#resource_label(resource_event_id) ⇒ Object



169
170
171
# File 'lib/labclient/merge_requests/merge_request.rb', line 169

def resource_label(resource_event_id)
  client.resource_labels.merge_requests.show(project_id, iid, resource_event_id)
end

#resource_labelsObject

Resource Labels



165
166
167
# File 'lib/labclient/merge_requests/merge_request.rb', line 165

def resource_labels
  client.resource_labels.merge_requests.list(project_id, iid)
end

#source_projectObject



123
124
125
# File 'lib/labclient/merge_requests/merge_request.rb', line 123

def source_project
  client.projects.show(source_project_id)
end

#subscribeObject



90
91
92
# File 'lib/labclient/merge_requests/merge_request.rb', line 90

def subscribe
  client.merge_requests.subscribe(project_id, iid)
end

#target_projectObject



127
128
129
# File 'lib/labclient/merge_requests/merge_request.rb', line 127

def target_project
  client.projects.show(target_project_id)
end

#time_estimate(duration) ⇒ Object



74
75
76
# File 'lib/labclient/merge_requests/merge_request.rb', line 74

def time_estimate(duration)
  client.merge_requests.time_estimate(project_id, iid, duration)
end

#time_statsObject



110
111
112
# File 'lib/labclient/merge_requests/merge_request.rb', line 110

def time_stats
  client.merge_requests.time_stats(project_id, iid)
end

#todoObject



106
107
108
# File 'lib/labclient/merge_requests/merge_request.rb', line 106

def todo
  client.merge_requests.todo(project_id, iid)
end

#unapproveObject



160
161
162
# File 'lib/labclient/merge_requests/merge_request.rb', line 160

def unapprove
  client.approvals.merge_request.unapprove(project_id, iid)
end

#unsubscribeObject



94
95
96
# File 'lib/labclient/merge_requests/merge_request.rb', line 94

def unsubscribe
  client.merge_requests.unsubscribe(project_id, iid)
end

#update(query) ⇒ Object



46
47
48
# File 'lib/labclient/merge_requests/merge_request.rb', line 46

def update(query)
  update_self client.merge_requests.update(project_id, iid, query)
end

#wait_for_merge_status(total_time = 300, sleep_time = 15) ⇒ Object

Wait for Import / Set a Hard Limit



179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/labclient/merge_requests/merge_request.rb', line 179

def wait_for_merge_status(total_time = 300, sleep_time = 15)
  # :unchecked
  # :cannot_be_merged_recheck
  # :checking
  # :cannot_be_merged_rechecking
  # :can_be_merged
  # :cannot_be_merged

  # Success
  # [unchecked, can_be_merged]

  # Fail
  # [cannot_be_merged cannot_be_merged_recheck]

  Timeout.timeout(total_time) do
    loop do
      reload
      puts "Waiting for Merge Status: #{merge_status}"
      break if %w[can_be_merged unchecked].include? merge_status
      raise "Cannot be merged! #{import_error}" if %w[cannot_be_merged cannot_be_merged_recheck].include? merge_status

      sleep sleep_time
    end
  end
end