lib/glman/commands/base.rb in glman-0.0.2 vs lib/glman/commands/base.rb in glman-0.0.3

- old
+ new

@@ -13,19 +13,29 @@ user_name = params[0] current_branch = git_repo.current_branch p 'You realy want to create merge request master to master ?' if current_branch == 'master' target_branch = params[2] || 'master' user_id = get_user_id(user_name) - message = params[1] || git_repo.last_commit_message || current_branch.split('_').join(' ') + message = params[1] || git_repo.last_commit_message || current_branch repository_name = git_repo.repository_name params = {assignee_id: user_id, title: message, source_branch: current_branch, target_branch: target_branch} + push_branch_first(push, current_branch) if push? + projects_repo.create_merge_request(repository_name, params) ap params.merge({user_name: user_name, repository_name: repository_name}) end + def push(origin) + @push = origin || 'origin' + end + + def push? + @push + end + def show=(bool) @show = bool end def show? @@ -105,9 +115,16 @@ when '' then puts '-' else puts "what ?" end end private + + attr_reader :push + + def push_branch_first(origin, branch) + p "push branch: #{branch} to origin: #{origin}" + git_repo.push(origin, branch) + end def show_all_mrs ap projects_repo.get_merge_requests(git_repo.repository_name) end \ No newline at end of file