Class: GitLab::MergeRequest
- Inherits:
-
Object
- Object
- GitLab::MergeRequest
- Defined in:
- lib/GitLab/merge_request.rb
Instance Attribute Summary collapse
-
#assignee_id ⇒ Object
Returns the value of attribute assignee_id.
-
#description ⇒ Object
Returns the value of attribute description.
-
#issue_iid ⇒ Object
Returns the value of attribute issue_iid.
-
#labels ⇒ Object
Returns the value of attribute labels.
-
#obj_gitlab ⇒ Object
Returns the value of attribute obj_gitlab.
-
#options ⇒ Object
Returns the value of attribute options.
-
#source_branch ⇒ Object
Returns the value of attribute source_branch.
-
#target_branch ⇒ Object
Returns the value of attribute target_branch.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #create ⇒ Object
- #create_code_review ⇒ Object
-
#initialize(params = {}) ⇒ MergeRequest
constructor
A new instance of MergeRequest.
Constructor Details
#initialize(params = {}) ⇒ MergeRequest
Returns a new instance of MergeRequest.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/GitLab/merge_request.rb', line 5 def initialize(params = {}) @source_branch = params[:source_branch] @target_branch = params[:target_branch] @title = params[:title] @labels = params[:labels] @issue_iid = params[:issue_iid] @type = params[:type] @description = params[:description] = params[:options] end |
Instance Attribute Details
#assignee_id ⇒ Object
Returns the value of attribute assignee_id.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def assignee_id @assignee_id end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def description @description end |
#issue_iid ⇒ Object
Returns the value of attribute issue_iid.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def issue_iid @issue_iid end |
#labels ⇒ Object
Returns the value of attribute labels.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def labels @labels end |
#obj_gitlab ⇒ Object
Returns the value of attribute obj_gitlab.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def obj_gitlab @obj_gitlab end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def end |
#source_branch ⇒ Object
Returns the value of attribute source_branch.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def source_branch @source_branch end |
#target_branch ⇒ Object
Returns the value of attribute target_branch.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def target_branch @target_branch end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/GitLab/merge_request.rb', line 3 def type @type end |
Instance Method Details
#create ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/GitLab/merge_request.rb', line 16 def create print "Create Merge Request: ".yellow print "#{@source_branch} into #{@target_branch}\n\n".green assignee_id = GitLab::User.me["id"] if type != 'hotfix' users = GitLab::User.all print "Users list:\n\n".yellow print "----------------------------\n".blue print "#{"0".ljust(10)} - Empty\n".blue users.each do |user| print "#{user['id'].to_s.ljust(10)} - #{user['name']}\n".blue end print "----------------------------\n".blue print "Choice user ID for assignee:\n".yellow assignee_id = STDIN.gets.chomp print "\n#{assignee_id}, " print "ok!\n".green end url = "projects/#{$GITLAB_PROJECT_ID}/merge_requests" labels = ['merge_request'] labels << type if type @obj_gitlab = GitLab.request_post(url, { source_branch: @source_branch, target_branch: @target_branch, title: @title, labels: labels.join(','), description: @description, assignee_id: assignee_id.to_i }) print "Merge request created with success!\n\n".green end |
#create_code_review ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/GitLab/merge_request.rb', line 52 def create_code_review print "Create merge request for code review: ".yellow print "#{@source_branch} into #{@target_branch}\n\n".green users = GitLab::User.all print "Users list:\n\n".yellow print "----------------------------\n".blue print "#{"0".ljust(10)} - Empty\n".blue users.each do |user| print "#{user['id'].to_s.ljust(10)} - #{user['name']}\n".blue end print "----------------------------\n".blue print "Choice user ID for assignee code review:\n".yellow assignee_id = STDIN.gets.chomp print "\n#{assignee_id}, " print "ok!\n".green url = "projects/#{$GITLAB_PROJECT_ID}/merge_requests" title = "WIP: ##{@issue_iid} - Code review #{@source_branch}" @obj_gitlab = GitLab.request_post(url, { source_branch: @source_branch, target_branch: @target_branch, title: title, labels: @labels, assignee_id: assignee_id.to_i }) print "Merge request for Code Review created with success!\n\n".green end |