Class: SupportOps::GitLab::MergeRequests
- Defined in:
- lib/support_ops_gitlab/gitlab/merge_requests.rb
Overview
Populate readonly_attributes
A lot of things listed at docs.gitlab.com/api/merge_requests
A lot of things listed at docs.gitlab.com/api/merge_request_approvals/
A lot of things listed at docs.gitlab.com/api/merge_request_approval_settings/
A lot of things listed at docs.gitlab.com/api/merge_request_context_commits/
List issues related to the merge request => docs.gitlab.com/api/merge_requests/#list-issues-related-to-the-merge-request
Defines the class MergeRequests within the module SupportOps::GitLab.
Instance Attribute Summary collapse
-
#allow_collaboration ⇒ Boolean
Allow commits from members who can merge to the target branch.
-
#allow_maintainer_to_push ⇒ Boolean
Alias of allow_collaboration.
-
#assignee ⇒ Hash
Information on the first merge request assignee.
-
#assignees ⇒ Array
An array of users assigned to the merge request.
-
#author ⇒ Hash
The author of the merge request.
-
#closed_at ⇒ String
The timestamp the merge request was closed at.
-
#closed_by ⇒ Hash
The user who closed the merge request.
-
#created_at ⇒ String
The timestamp of when the ismerge requestsue was created.
-
#description ⇒ String
The merge request’s description.
-
#detailed_merge_status ⇒ String
Detailed merge status of the merge request.
-
#discussion_locked ⇒ Boolean
If discussion on the merge request is locked or not.
-
#downvotes ⇒ Integer
The number of downvotes the merge request has.
-
#draft ⇒ Boolean
If the merge request is in draft mode or not.
-
#force_remove_source_branch ⇒ Boolean
Indicates if the project settings lead to source branch deletion after merge.
-
#id ⇒ Integer
The global ID or URL-encoded path of the project.
-
#iid ⇒ Integer
The internal ID of a project’s merge request.
-
#imported ⇒ Boolean
If the merge request was imported or not.
-
#imported_from ⇒ String
The current value of imported_from.
-
#labels ⇒ Array
Comma-separated list of label names.
-
#merge_after ⇒ String
Date after which the merge request can be merged.
-
#merge_commit_sha ⇒ String
SHA of the merge request commit; returns null until merged.
-
#merge_status ⇒ String
Status of the merge request; can be unchecked, checking, can_be_merged, cannot_be_merged, or cannot_be_merged_recheck.
-
#merge_user ⇒ String
The user who merged this merge request, the user who set it to auto-merge, or null.
-
#merge_when_pipeline_succeeds ⇒ Boolean
Indicates if the merge is set to merge when its pipeline succeeds.
-
#merged_at ⇒ String
The timestamp the merge request was merged.
-
#milestone ⇒ Hash
The milestone the merge request is attached to.
-
#prepared_at ⇒ String
Timestamp of when the merge request was prepared; this field populates one time, only after all the preparation steps complete, and is not updated if more changes are added.
-
#project_id ⇒ Integer
The ID of the project the merge request is within.
-
#references ⇒ Hash
Reference tags for the merge request.
-
#reviewers ⇒ Array
Reviewers of the merge request.
-
#sha ⇒ String
Diff head SHA of the merge request.
-
#should_remove_source_branch ⇒ Boolean
Indicates if the source branch of the merge request should be deleted after merge.
-
#source_branch ⇒ String
Source branch of the merge request.
-
#source_project_id ⇒ Integer
ID of the merge request source project.
-
#squash ⇒ Boolean
Indicates if squash on merge is enabled.
-
#squash_commit_sha ⇒ String
SHA of the squash commit; empty until merged.
-
#state ⇒ String
The current state of the merge request.
-
#target_branch ⇒ String
Target branch of the merge request.
-
#target_project_id ⇒ Integer
ID of the merge request target project.
-
#task_completion_status ⇒ Hash
Information on the task status of a merge request.
-
#time_stats ⇒ Hash
Information on the time spent on the merge request.
-
#title ⇒ String
The mnerge request title.
-
#updated_at ⇒ String
The timestamp of when the merge request was last updated.
-
#upvotes ⇒ Integer
The number of upvotes on a merge request.
-
#user_notes_count ⇒ Integer
The number of notes on the merge request.
-
#web_url ⇒ String
The URL of the merge request.
Class Method Summary collapse
-
.get(object) ⇒ Object
Locates a specific merge request in the GitLab system.
-
.get!(object) ⇒ Object
Locates a specific merge request in the GitLab system.
-
.list(key: value) ⇒ Array
Lists issues.
Instance Method Summary collapse
-
#diffs ⇒ Boolean
List diffs on a merge request.
-
#notes ⇒ Boolean
List notes on a merge request.
-
#subscribe! ⇒ Object
Subscribe to a merge request.
-
#unsubscribe! ⇒ Object
Unsubscribe to a merge request.
Methods inherited from Base
#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #delete!, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #ssh_keys, #status, #store_original_attributes, #support_pin, to_hash, #tokens, #unban!, #unblock!, #webhooks
Constructor Details
This class inherits a constructor from SupportOps::GitLab::Base
Instance Attribute Details
#allow_collaboration ⇒ Boolean
Allow commits from members who can merge to the target branch
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def allow_collaboration @allow_collaboration end |
#allow_maintainer_to_push ⇒ Boolean
Alias of allow_collaboration
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def allow_maintainer_to_push @allow_maintainer_to_push end |
#assignee ⇒ Hash
Information on the first merge request assignee
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def assignee @assignee end |
#assignees ⇒ Array
An array of users assigned to the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def assignees @assignees end |
#author ⇒ Hash
The author of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def @author end |
#closed_at ⇒ String
The timestamp the merge request was closed at
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def closed_at @closed_at end |
#closed_by ⇒ Hash
The user who closed the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def closed_by @closed_by end |
#created_at ⇒ String
The timestamp of when the ismerge requestsue was created
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def created_at @created_at end |
#description ⇒ String
The merge request’s description
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def description @description end |
#detailed_merge_status ⇒ String
Detailed merge status of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def detailed_merge_status @detailed_merge_status end |
#discussion_locked ⇒ Boolean
If discussion on the merge request is locked or not
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def discussion_locked @discussion_locked end |
#downvotes ⇒ Integer
The number of downvotes the merge request has
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def downvotes @downvotes end |
#draft ⇒ Boolean
If the merge request is in draft mode or not
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def draft @draft end |
#force_remove_source_branch ⇒ Boolean
Indicates if the project settings lead to source branch deletion after merge
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def force_remove_source_branch @force_remove_source_branch end |
#id ⇒ Integer
The global ID or URL-encoded path of the project
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def id @id end |
#iid ⇒ Integer
The internal ID of a project’s merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def iid @iid end |
#imported ⇒ Boolean
If the merge request was imported or not
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def imported @imported end |
#imported_from ⇒ String
Returns the current value of imported_from.
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def imported_from @imported_from end |
#labels ⇒ Array
Comma-separated list of label names
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def labels @labels end |
#merge_after ⇒ String
Date after which the merge request can be merged
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merge_after @merge_after end |
#merge_commit_sha ⇒ String
SHA of the merge request commit; returns null until merged
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merge_commit_sha @merge_commit_sha end |
#merge_status ⇒ String
Status of the merge request; can be unchecked, checking, can_be_merged, cannot_be_merged, or cannot_be_merged_recheck. Affects the has_conflicts property
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merge_status @merge_status end |
#merge_user ⇒ String
The user who merged this merge request, the user who set it to auto-merge, or null
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merge_user @merge_user end |
#merge_when_pipeline_succeeds ⇒ Boolean
Indicates if the merge is set to merge when its pipeline succeeds
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merge_when_pipeline_succeeds @merge_when_pipeline_succeeds end |
#merged_at ⇒ String
The timestamp the merge request was merged
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def merged_at @merged_at end |
#milestone ⇒ Hash
The milestone the merge request is attached to
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def milestone @milestone end |
#prepared_at ⇒ String
Timestamp of when the merge request was prepared; this field populates one time, only after all the preparation steps complete, and is not updated if more changes are added
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def prepared_at @prepared_at end |
#project_id ⇒ Integer
The ID of the project the merge request is within
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def project_id @project_id end |
#references ⇒ Hash
Reference tags for the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def references @references end |
#reviewers ⇒ Array
Reviewers of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def reviewers @reviewers end |
#sha ⇒ String
Diff head SHA of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def sha @sha end |
#should_remove_source_branch ⇒ Boolean
Indicates if the source branch of the merge request should be deleted after merge
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def should_remove_source_branch @should_remove_source_branch end |
#source_branch ⇒ String
Source branch of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def source_branch @source_branch end |
#source_project_id ⇒ Integer
ID of the merge request source project
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def source_project_id @source_project_id end |
#squash ⇒ Boolean
Indicates if squash on merge is enabled
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def squash @squash end |
#squash_commit_sha ⇒ String
SHA of the squash commit; empty until merged.
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def squash_commit_sha @squash_commit_sha end |
#state ⇒ String
The current state of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def state @state end |
#target_branch ⇒ String
Target branch of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def target_branch @target_branch end |
#target_project_id ⇒ Integer
ID of the merge request target project
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def target_project_id @target_project_id end |
#task_completion_status ⇒ Hash
Information on the task status of a merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def task_completion_status @task_completion_status end |
#time_stats ⇒ Hash
Information on the time spent on the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def time_stats @time_stats end |
#title ⇒ String
The mnerge request title
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def title @title end |
#updated_at ⇒ String
The timestamp of when the merge request was last updated
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def updated_at @updated_at end |
#upvotes ⇒ Integer
The number of upvotes on a merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def upvotes @upvotes end |
#user_notes_count ⇒ Integer
The number of notes on the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def user_notes_count @user_notes_count end |
#web_url ⇒ String
The URL of the merge request
64 65 66 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 64 def web_url @web_url end |
Class Method Details
.get(object) ⇒ Object
Locates a specific merge request in the GitLab system
339 340 341 342 343 344 345 346 347 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 339 def self.get(object) if object.is_a? MergeRequests MergeRequests.new(id: id).find elsif object.is_a? Hash MergeRequests.new({ id: object[:id], iid: object[:iid], project_id: object[:project_id] }).find else MergeRequests.new(id: object).find end end |
.get!(object) ⇒ Object
Locates a specific merge request in the GitLab system
386 387 388 389 390 391 392 393 394 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 386 def self.get!(object) if object.is_a? MergeRequests MergeRequests.new(id: id).find! elsif object.is_a? Hash MergeRequests.new({ id: object[:id], iid: object[:iid], project_id: object[:project_id] }).find! else MergeRequests.new(id: object).find! end end |
.list(key: value) ⇒ Array
Lists issues
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 224 def self.list(**args) args[:approved] = nil unless args[:approved] args[:approved_by_ids] = nil unless args[:approved_by_ids] args[:approved_by_usernames] = nil unless args[:approved_by_usernames] args[:approver_ids] = nil unless args[:approver_ids] args[:assignee_id] = nil unless args[:assignee_id] args[:author_id] = nil unless args[:author_id] args[:author_username] = nil unless args[:author_username] args[:created_after] = nil unless args[:created_after] args[:created_before] = nil unless args[:created_before] args[:labels] = nil unless args[:labels] args[:merge_user_id] = nil unless args[:merge_user_id] args[:merge_user_username] = nil unless args[:merge_user_username] args[:milestone] = nil unless args[:milestone] args[:my_reaction_emoji] = nil unless args[:my_reaction_emoji] args[:non_archived] = nil unless args[:non_archived] args[:order_by] = nil unless args[:order_by] args[:project_id] = nil unless args[:project_id] args[:reviewer_id] = nil unless args[:reviewer_id] args[:reviewer_username] = nil unless args[:reviewer_username] args[:scope] = nil unless args[:scope] args[:search] = nil unless args[:search] args[:sort] = nil unless args[:sort] args[:source_branch] = nil unless args[:source_branch] args[:state] = nil unless args[:state] args[:target_branch] = nil unless args[:target_branch] args[:updated_after] = nil unless args[:updated_after] args[:updated_before] = nil unless args[:updated_before] args[:limit] = 0 unless args[:limit] params = '' params += "approved=#{args[:approved]}&" unless args[:approved].nil? params += "approved_by_ids=#{args[:approved_by_ids]}&" unless args[:approved_by_ids].nil? params += "approved_by_usernames=#{args[:approved_by_usernames]}&" unless args[:approved_by_usernames].nil? params += "approver_ids=#{args[:approver_ids]}&" unless args[:approver_ids].nil? params += "assignee_id=#{args[:assignee_id]}&" unless args[:assignee_id].nil? params += "author_id=#{args[:author_id]}&" unless args[:author_id].nil? params += "author_username=#{args[:author_username]}&" unless args[:author_username].nil? params += "created_after=#{args[:created_after]}&" unless args[:created_after].nil? params += "created_before=#{args[:created_before]}&" unless args[:created_before].nil? params += "labels=#{args[:labels]}&" unless args[:labels].nil? params += "merge_user_id=#{args[:merge_user_id]}&" unless args[:merge_user_id].nil? params += "merge_user_username=#{args[:merge_user_username]}&" unless args[:merge_user_username].nil? params += "milestone=#{args[:milestone]}&" unless args[:milestone].nil? params += "my_reaction_emoji=#{args[:my_reaction_emoji]}&" unless args[:my_reaction_emoji].nil? params += "non_archived=#{args[:non_archived]}&" unless args[:non_archived].nil? params += "order_by=#{args[:order_by]}&" unless args[:order_by].nil? params += "project_id=#{args[:project_id]}&" unless args[:project_id].nil? params += "reviewer_id=#{args[:reviewer_id]}&" unless args[:reviewer_id].nil? params += "reviewer_username=#{args[:reviewer_username]}&" unless args[:reviewer_username].nil? params += "scope=#{args[:scope]}&" unless args[:scope].nil? params += "search=#{args[:search]}&" unless args[:search].nil? params += "sort=#{args[:sort]}&" unless args[:sort].nil? params += "source_branch=#{args[:source_branch]}&" unless args[:source_branch].nil? params += "state=#{args[:state]}&" unless args[:state].nil? params += "target_branch=#{args[:target_branch]}&" unless args[:target_branch].nil? params += "updated_after=#{args[:updated_after]}&" unless args[:updated_after].nil? params += "updated_before=#{args[:updated_before]}&" unless args[:updated_before].nil? array = [] page = 1 base_url = if args[:project_id].nil? "merge_requests" else "projects/#{args[:project_id]}/merge_requests" end loop do response = client.connection.get("#{base_url}?#{params}&page=#{page}&per_page=100") body = Oj.load(response.body) array += body.map { |m| MergeRequests.new(m) } break if args[:limit].to_i.positive? && array.count >= args[:limit].to_i break if body.count < 100 page += 1 end return array if args[:limit].to_i.zero? array.first(args[:limit].to_i) end |
Instance Method Details
#diffs ⇒ Boolean
This is inherited from Base#diffs
List diffs on a merge request
24 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 24 def diffs; end |
#notes ⇒ Boolean
This is inherited from Base#notes
List notes on a merge request
22 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 22 def notes; end |
#subscribe! ⇒ Object
This is inherited from Base#subscribe!
Subscribe to a merge request
20 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 20 def subscribe!; end |
#unsubscribe! ⇒ Object
This is inherited from Base#unsubscribe!
Unsubscribe to a merge request
20 |
# File 'lib/support_ops_gitlab/gitlab/merge_requests.rb', line 20 def unsubscribe!; end |