Class: Readiness::GitLab::MergeRequests
- Defined in:
- lib/support_readiness/gitlab/merge_requests.rb
Overview
Defines the class MergeRequests within the module Readiness::GitLab.
Class Method Summary collapse
-
.comments(client, project, iid) ⇒ Array
Get all comments on a project merge request within GitLab.
-
.create_comment!(client, project, iid, params) ⇒ Hash
Create a comment on a project merge request within GitLab.
-
.find(client, project, iid) ⇒ Hash
Locates a project merge request within GitLab.
-
.find!(client, project, iid) ⇒ Hash
Locates a project merge request within GitLab.
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Class Method Details
.comments(client, project, iid) ⇒ Array
Get all comments on a project merge request within GitLab.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/support_readiness/gitlab/merge_requests.rb', line 81 def self.comments(client, project, iid) array = [] page = 1 loop do response = client.connection.get "projects/#{project.id}/merge_requests/#{iid}/notes?per_page=100&page=#{page}" handle_request_error(0, 'GitLab', response.status) unless response.status == 200 body = Oj.load(response.body) array += body break if body.count < 100 page += 1 end array end |
.create_comment!(client, project, iid, params) ⇒ Hash
Create a comment on a project merge request within GitLab.
120 121 122 123 124 |
# File 'lib/support_readiness/gitlab/merge_requests.rb', line 120 def self.create_comment!(client, project, iid, params) response = client.connection.post "projects/#{project.id}/merge_requests/#{iid}/notes", params.to_json handle_request_error(1, 'GitLab', response.status, { action: 'Create MR comment', id: "projects/#{project.id}/merge_requests/#{iid}" }) unless response.status == 200 Oj.load(response.body) end |
.find(client, project, iid) ⇒ Hash
Locates a project merge request within GitLab. This will not exit on error (except Authentication errors)
32 33 34 35 |
# File 'lib/support_readiness/gitlab/merge_requests.rb', line 32 def self.find(client, project, iid) response = client.connection.get "projects/#{project.id}/merge_requests/#{iid}" Oj.load(response.body) end |
.find!(client, project, iid) ⇒ Hash
Locates a project merge request within GitLab. This will exit on error
56 57 58 59 60 |
# File 'lib/support_readiness/gitlab/merge_requests.rb', line 56 def self.find!(client, project, iid) response = client.connection.get "projects/#{project.id}/merge_requests/#{iid}" handle_request_error(1, 'GitLab', response.status, { action: 'Find MR', id: "projects/#{project.id}/merge_requests/#{iid}" }) unless response.status == 200 Oj.load(response.body) end |