Commit b4bc9bd5 authored by Sean McGivern's avatar Sean McGivern

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
parents 6b314f7b 7e9484e9
...@@ -54,6 +54,7 @@ module MergeRequests ...@@ -54,6 +54,7 @@ module MergeRequests
source_project_id: project.id, source_project_id: project.id,
source_branch: branch_name, source_branch: branch_name,
target_project_id: project.id, target_project_id: project.id,
target_branch: ref,
milestone_id: issue.milestone_id milestone_id: issue.milestone_id
} }
end end
......
---
title: Set target_branch to the ref branch when creating MR from issue
merge_request:
author:
type: fixed
...@@ -112,5 +112,24 @@ describe MergeRequests::CreateFromIssueService do ...@@ -112,5 +112,24 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].assignee).to eq(user) expect(result[:merge_request].assignee).to eq(user)
end 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
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