Commit e1f9f3c6 authored by Sean McGivern's avatar Sean McGivern

Merge branch...

Merge branch '45400-automatically-created-mr-uses-wrong-target-branch-when-branching-from-tag' into 'master'

Resolve "Automatically created MR uses wrong target branch (when branching from Tag)"

Closes #45400

See merge request gitlab-org/gitlab-ce!19067
parents f068479e c22e51e8
No related merge requests found
......@@ -41,7 +41,9 @@ module MergeRequests
end
def ref
@ref || project.default_branch || 'master'
return @ref if project.repository.branch_exists?(@ref)
project.default_branch || 'master'
end
def merge_request
......
---
title: Set MR target branch to default branch if target branch is not valid
merge_request: 19067
author:
type: fixed
......@@ -125,9 +125,14 @@ describe MergeRequests::CreateFromIssueService do
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 }
subject { described_class.new(project, user, issue_iid: issue.iid, ref: 'no-such-branch').execute }
it 'creates a merge request' do
expect { subject }.to change(project.merge_requests, :count).by(1)
end
it 'sets the merge request target branch to the project default branch' do
expect(subject[:merge_request].target_branch).to eq(project.default_branch)
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