Commit 0c73e666 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Specify error codes for merge api

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent fe6d3922
...@@ -130,22 +130,25 @@ module API ...@@ -130,22 +130,25 @@ module API
end end
if can?(current_user, action, project) if can?(current_user, action, project)
# Check if MR can be merged by GitLab
if merge_request.unchecked? if merge_request.unchecked?
merge_request.check_if_can_be_merged merge_request.check_if_can_be_merged
end end
if merge_request.open? && merge_request.can_be_merged? if merge_request.open?
merge_request.automerge!(current_user, params[:merge_commit_message] || merge_request.merge_commit_message) if merge_request.can_be_merged?
merge_request.automerge!(current_user, params[:merge_commit_message] || merge_request.merge_commit_message)
# return success else
render_api_error!('Branch cannot be merged', 405)
end
else else
# Merge request can not be merged
# Checkif can be merged # because it is already closed/merged
not_allowed!
end end
else else
# not allowed # Merge request can not be merged
# because user dont have permissions to push into target branch
unauthorized!
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment