lib/glman/commands/base.rb in glman-0.0.7 vs lib/glman/commands/base.rb in glman-0.0.8
- old
+ new
@@ -10,21 +10,44 @@
# merge_request user_name/email message target_branch
def mr(params)
return show_all_mrs if show?
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'
+
+ if current_branch == 'master'
+ p 'Merge request from master to master is not so good idea!'
+ return
+ end
+
target_branch = params[2] || 'master'
user_id = get_user_id(user_name)
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(origin, current_branch) unless origin.nil?
- projects_repo.create_merge_request(repository_name, params)
- ap params.merge({user_name: user_name, repository_name: repository_name})
+ opts = projects_repo.create_merge_request(repository_name, params)
+ assignee = opts['assignee'] || {}
+ author = opts['author'] || {}
+ info = {
+ url: "#{configuration.load[:gitlab_url]}/resfinity/resfinity_profile/merge_requests/#{opts['iid']}",
+ assignee: {
+ username: assignee['username'],
+ email: assignee['email'],
+ name: assignee['name']
+ },
+ author: {
+ username: author['username'],
+ email: author['email'],
+ name: author['name']
+ },
+ id: opts['id'],
+ iid: opts['iid'],
+ created_at: assignee['created_at']
+ }
+ ap params.merge({repository_name: repository_name}.merge(info))
end
def push=(origin=nil)
@origin = origin || 'origin'
end
\ No newline at end of file