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
This commit is contained in:
commit
e1f9f3c6ac
3 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue