Commit c85a768c authored by Nick Thomas's avatar Nick Thomas

Respect the should_remove_source_branch parameter to the merge API

parent d93d799b
---
title: Respect the should_remove_source_branch parameter to the merge API
merge_request: 25525
author:
type: fixed
...@@ -369,11 +369,11 @@ module API ...@@ -369,11 +369,11 @@ module API
merge_request.update(squash: params[:squash]) if params[:squash] merge_request.update(squash: params[:squash]) if params[:squash]
merge_params = { merge_params = HashWithIndifferentAccess.new(
commit_message: params[:merge_commit_message], commit_message: params[:merge_commit_message],
squash_commit_message: params[:squash_commit_message], squash_commit_message: params[:squash_commit_message],
should_remove_source_branch: params[:should_remove_source_branch] should_remove_source_branch: params[:should_remove_source_branch]
} )
if merge_when_pipeline_succeeds && merge_request.head_pipeline && merge_request.head_pipeline.active? if merge_when_pipeline_succeeds && merge_request.head_pipeline && merge_request.head_pipeline.active?
::MergeRequests::MergeWhenPipelineSucceedsService ::MergeRequests::MergeWhenPipelineSucceedsService
......
...@@ -984,6 +984,21 @@ describe API::MergeRequests do ...@@ -984,6 +984,21 @@ describe API::MergeRequests do
expect(squash_commit.message).to eq(merge_request.default_squash_commit_message) expect(squash_commit.message).to eq(merge_request.default_squash_commit_message)
end end
end end
describe "the should_remove_source_branch param" do
let(:source_repository) { merge_request.source_project.repository }
let(:source_branch) { merge_request.source_branch }
it 'removes the source branch when set' do
put(
api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user),
params: { should_remove_source_branch: true }
)
expect(response).to have_gitlab_http_status(200)
expect(source_repository.branch_exists?(source_branch)).to be_falsy
end
end
end end
describe "PUT /projects/:id/merge_requests/:merge_request_iid" do describe "PUT /projects/:id/merge_requests/:merge_request_iid" do
......
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