diff options
author | Nick Thomas <nick@gitlab.com> | 2018-11-22 09:02:58 +0300 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-11-27 21:04:33 +0300 |
commit | 9f287298270b3a833bc53b9280c6e3c6a2f055b8 (patch) | |
tree | 3283dc7f49b6ec62f23e89f1811a539b21461b82 /lib | |
parent | 0afce35d65aa433d221e41632c6d8095ab68c39f (diff) |
Add a rebase API endpoint for merge requests
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 16f07f16387..23e65dca424 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -74,6 +74,19 @@ module API options end + def authorize_push_to_merge_request!(merge_request) + forbidden!('Source branch does not exist') unless + merge_request.source_branch_exists? + + user_access = Gitlab::UserAccess.new( + current_user, + project: merge_request.source_project + ) + + forbidden!('Cannot push to source branch') unless + user_access.can_push_to_branch?(merge_request.source_branch) + end + params :merge_requests_params do optional :state, type: String, values: %w[opened closed locked merged all], default: 'all', desc: 'Return opened, closed, locked, merged, or all merge requests' @@ -378,6 +391,19 @@ module API .cancel(merge_request) end + desc 'Rebase the merge request against its target branch' do + detail 'This feature was added in GitLab 11.6' + end + put ':id/merge_requests/:merge_request_iid/rebase' do + merge_request = find_project_merge_request(params[:merge_request_iid]) + + authorize_push_to_merge_request!(merge_request) + + RebaseWorker.perform_async(merge_request.id, current_user.id) + + status :accepted + end + desc 'List issues that will be closed on merge' do success Entities::MRNote end |