Class: GitLab::MergeRequest
- Inherits:
-
Object
- Object
- GitLab::MergeRequest
- Includes:
- TtyIntegration
- 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.
Methods included from TtyIntegration
#bar, #cmd, #error, #green, #pastel, #prompt, #red, #success, #table, #yellow
Constructor Details
#initialize(params = {}) ⇒ MergeRequest
Returns a new instance of MergeRequest.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/GitLab/merge_request.rb', line 10 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] @options = params[:options] end |
Instance Attribute Details
#assignee_id ⇒ Object
Returns the value of attribute assignee_id.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def assignee_id @assignee_id end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def description @description end |
#issue_iid ⇒ Object
Returns the value of attribute issue_iid.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def issue_iid @issue_iid end |
#labels ⇒ Object
Returns the value of attribute labels.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def labels @labels end |
#obj_gitlab ⇒ Object
Returns the value of attribute obj_gitlab.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def obj_gitlab @obj_gitlab end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def @options end |
#source_branch ⇒ Object
Returns the value of attribute source_branch.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def source_branch @source_branch end |
#target_branch ⇒ Object
Returns the value of attribute target_branch.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def target_branch @target_branch end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/GitLab/merge_request.rb', line 6 def type @type end |
Instance Method Details
#create ⇒ Object
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 50 51 52 53 54 55 56 57 |
# File 'lib/GitLab/merge_request.rb', line 21 def create # 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 users_list = GitLab::User.all.map { |u| "#{u['id']} - #{u['name']}" } user_selected = prompt.select('Quem vai aprovar o MR?', users_list, symbols: { marker: '>' }, filter: true) assignee_id = user_selected.delete("\n").split('-')[0].strip 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, squash: true, squash_on_merge: true }) prompt.say(pastel.cyan("Merge request criado com sucesso!\n\n")) end |
#create_code_review ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/GitLab/merge_request.rb', line 59 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 users = GitLab::User.all assignee_id = prompt.select('Quem vai fazer o codereview?', symbols: { marker: '>' }, filter: true) do || users.each do |user| .choice user['name'], user['id'] end end url = "projects/#{$GITLAB_PROJECT_ID}/merge_requests" title = "Draft: ##{@issue_iid} - Code review #{@source_branch}" description = 'Este Merge Request de codereview foi criado pelo gitsflow' @obj_gitlab = GitLab.request_post(url, { source_branch: @source_branch, target_branch: @target_branch, title: title, description: description, labels: @labels, assignee_id: GitLab::User.me['id'].to_i, reviewer_ids: [assignee_id.to_i] }) return error(@obj_gitlab.dig('message').join('.')) if @obj_gitlab.has_key? 'message' success("Code Review criado com sucesso!\n\n") # print "Merge request for Code Review created with success!\n\n".green end |