From fe59547ae5b272a183253c31e5273d52d0a02381 Mon Sep 17 00:00:00 2001 From: Valeriy Sizov Date: Sun, 21 Oct 2012 14:41:06 +0300 Subject: [PATCH] API: create merge request --- lib/api/merge_requests.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 12c9647b..fd741585 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -18,7 +18,17 @@ module Gitlab #create merge_request post ":id/merge_requests" do - + attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title] + project = current_user.projects.find(params[:id]) + merge_request = project.merge_requests.new(attrs) + merge_request.author = current_user + + if merge_request.save + merge_request.reload_code + present merge_request, with: Entities::MergeRequest + else + not_found! + end end #update merge_request