diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-12 17:51:43 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-05-12 17:51:43 +0300 |
commit | 0c73e6664389ef5af352560c2fced1fbfc650a27 (patch) | |
tree | e92fa34933a220c349e402f32f74f749f11e319f /lib | |
parent | fe6d392236fb6f1edd5dc1c33d52806cb4fa8a39 (diff) | |
download | gitlab-ce-0c73e6664389ef5af352560c2fced1fbfc650a27.tar.gz |
Specify error codes for merge api
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index fe615dfac05..f9a4037dd26 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -130,22 +130,25 @@ module API end if can?(current_user, action, project) - # Check if MR can be merged by GitLab if merge_request.unchecked? merge_request.check_if_can_be_merged end - if merge_request.open? && merge_request.can_be_merged? - merge_request.automerge!(current_user, params[:merge_commit_message] || merge_request.merge_commit_message) - - # return success + if merge_request.open? + if merge_request.can_be_merged? + merge_request.automerge!(current_user, params[:merge_commit_message] || merge_request.merge_commit_message) + else + render_api_error!('Branch cannot be merged', 405) + end else - - # Checkif can be merged + # Merge request can not be merged + # because it is already closed/merged + not_allowed! end - else - # not allowed + # Merge request can not be merged + # because user dont have permissions to push into target branch + unauthorized! end end |