class GitLab::MergeRequest
Attributes
assignee_id[RW]
description[RW]
issue_iid[RW]
labels[RW]
obj_gitlab[RW]
options[RW]
source_branch[RW]
target_branch[RW]
title[RW]
type[RW]
Public Class Methods
new(params = {})
click to toggle source
# 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] @options = params[:options] end
Public Instance Methods
create()
click to toggle source
# 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()
click to toggle source
# 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