BigW Consortium Gitlab

Commit 41d782ed by Sean McGivern Committed by Tiago Botelho

Merge branch '41727-target-branch-name' into 'master'

Set target_branch to the ref branch when creating MR from issue Closes #41727 See merge request gitlab-org/gitlab-ce!16422 (cherry picked from commit b4bc9bd5) 7e9484e9 Set target_branch to the ref branch when creating MR from issue
parent 593effca
......@@ -54,6 +54,7 @@ module MergeRequests
source_project_id: project.id,
source_branch: branch_name,
target_project_id: project.id,
target_branch: ref,
milestone_id: issue.milestone_id
}
end
......
---
title: Set target_branch to the ref branch when creating MR from issue
merge_request:
author:
type: fixed
......@@ -100,5 +100,36 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].target_branch).to eq(project.default_branch)
end
it 'executes quick actions if the build service sets them in the description' do
allow(service).to receive(:merge_request).and_wrap_original do |m, *args|
m.call(*args).tap do |merge_request|
merge_request.description = "/assign #{user.to_reference}"
end
end
result = service.execute
expect(result[:merge_request].assignee).to eq(user)
end
context 'when ref branch is set' do
subject { described_class.new(project, user, issue_iid: issue.iid, ref: 'feature').execute }
it 'sets the merge request source branch to the new issue branch' do
expect(subject[:merge_request].source_branch).to eq(issue.to_branch_name)
end
it 'sets the merge request target branch to the ref branch' do
expect(subject[:merge_request].target_branch).to eq('feature')
end
context 'when ref branch does not exist' do
it 'does not create a merge request' do
expect { described_class.new(project, user, issue_iid: issue.iid, ref: 'nobr').execute }
.not_to change { project.merge_requests.count }
end
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