Commit 959ad992 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Ref merge does not fail upon FF config enabled

parent 81a0cc25
......@@ -20,7 +20,7 @@ module MergeRequests
raise_error('Conflicts detected during merge') unless commit_id
success(commit_id: commit_id)
success(commit_id: commit_id, source_id: source)
rescue MergeError => error
error(error.message)
end
......@@ -38,12 +38,8 @@ module MergeRequests
error =
if Feature.disabled?(:merge_to_tmp_merge_ref_path, project)
'Feature is not enabled'
elsif !merge_method_supported?
"#{project.human_merge_method} to #{target_ref} is currently not supported."
elsif !hooks_validation_pass?(merge_request)
hooks_validation_error(merge_request)
elsif @merge_request.should_be_rebased?
'Fast-forward merge is not possible. Please update your source branch.'
elsif !@merge_request.mergeable_to_ref?
"Merge request is not mergeable to #{target_ref}"
elsif !source
......@@ -68,9 +64,5 @@ module MergeRequests
rescue Gitlab::Git::PreReceiveError => error
raise MergeError, error.message
end
def merge_method_supported?
[:merge, :rebase_merge].include?(project.merge_method)
end
end
end
......@@ -52,6 +52,7 @@ describe MergeRequests::MergeToRefService do
expect(result[:status]).to eq(:success)
expect(result[:commit_id]).to be_present
expect(result[:source_id]).to eq(merge_request.source_branch_sha)
expect(repository.ref_exists?(target_ref)).to be(true)
expect(ref_head.id).to eq(result[:commit_id])
end
......@@ -115,41 +116,7 @@ describe MergeRequests::MergeToRefService do
end
context 'merge pre-condition checks' do
before do
merge_request.project.update!(merge_method: merge_method)
end
context 'when semi-linear merge method' do
let(:merge_method) { :rebase_merge }
it 'return error when MR should be able to fast-forward' do
allow(merge_request).to receive(:should_be_rebased?) { true }
error_message = 'Fast-forward merge is not possible. Please update your source branch.'
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq(error_message)
end
end
context 'when fast-forward merge method' do
let(:merge_method) { :ff }
it 'returns error' do
error_message = "Fast-forward to #{merge_request.merge_ref_path} is currently not supported."
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq(error_message)
end
end
context 'when MR is not mergeable to ref' do
let(:merge_method) { :merge }
it 'returns error' do
allow(merge_request).to receive(:mergeable_to_ref?) { false }
......
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