Commit c8eb789b authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix/import-export-arguments' into 'master'

Fix arguments error on Import/Export fetch_ref method

Closes #39541

See merge request gitlab-org/gitlab-ce!15241
parents 4e00e8ed 9a0acc98
---
title: Fix arguments Import/Export error importing project merge requests
merge_request:
author:
type: fixed
...@@ -26,7 +26,7 @@ module Gitlab ...@@ -26,7 +26,7 @@ module Gitlab
end end
def fetch_ref def fetch_ref
@project.repository.fetch_ref(@project.repository.path, @diff_head_sha, @merge_request.source_branch) @project.repository.fetch_ref(@project.repository, source_ref: @diff_head_sha, target_ref: @merge_request.source_branch)
end end
def branch_exists?(branch_name) def branch_exists?(branch_name)
......
...@@ -13,7 +13,7 @@ describe Gitlab::ImportExport::MergeRequestParser do ...@@ -13,7 +13,7 @@ describe Gitlab::ImportExport::MergeRequestParser do
let(:parsed_merge_request) do let(:parsed_merge_request) do
described_class.new(project, described_class.new(project,
merge_request.diff_head_sha, 'abcd',
merge_request, merge_request,
merge_request.as_json).parse! merge_request.as_json).parse!
end end
...@@ -29,4 +29,14 @@ describe Gitlab::ImportExport::MergeRequestParser do ...@@ -29,4 +29,14 @@ describe Gitlab::ImportExport::MergeRequestParser do
it 'has a target branch' do it 'has a target branch' do
expect(project.repository.branch_exists?(parsed_merge_request.target_branch)).to be true expect(project.repository.branch_exists?(parsed_merge_request.target_branch)).to be true
end end
it 'parses a MR that has no source branch' do
allow_any_instance_of(described_class).to receive(:branch_exists?).and_call_original
allow_any_instance_of(described_class).to receive(:branch_exists?).with(merge_request.source_branch).and_return(false)
allow_any_instance_of(described_class).to receive(:fork_merge_request?).and_return(true)
allow(Gitlab::GitalyClient).to receive(:migrate).and_call_original
allow(Gitlab::GitalyClient).to receive(:migrate).with(:fetch_ref).and_return([nil, 0])
expect(parsed_merge_request).to eq(merge_request)
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