Commit fb9bd552 authored by James Lopez's avatar James Lopez

Fix fork MRs importing issue

parent 646aae3e
...@@ -133,5 +133,7 @@ methods: ...@@ -133,5 +133,7 @@ methods:
- :utf8_diff - :utf8_diff
merge_requests: merge_requests:
- :diff_head_sha - :diff_head_sha
- :source_branch_sha
- :target_branch_sha
project: project:
- :description_html - :description_html
...@@ -30,7 +30,7 @@ module Gitlab ...@@ -30,7 +30,7 @@ module Gitlab
end end
def branch_exists?(branch_name) def branch_exists?(branch_name)
@project.repository.branch_exists?(branch_name) @project.repository.raw.branch_exists?(branch_name)
end end
def fork_merge_request? def fork_merge_request?
......
...@@ -2522,7 +2522,7 @@ ...@@ -2522,7 +2522,7 @@
"id": 27, "id": 27,
"target_branch": "feature", "target_branch": "feature",
"source_branch": "feature_conflict", "source_branch": "feature_conflict",
"source_project_id": 5, "source_project_id": 999,
"author_id": 1, "author_id": 1,
"assignee_id": null, "assignee_id": null,
"title": "MR1", "title": "MR1",
...@@ -2536,6 +2536,9 @@ ...@@ -2536,6 +2536,9 @@
"position": 0, "position": 0,
"updated_by_id": null, "updated_by_id": null,
"merge_error": null, "merge_error": null,
"diff_head_sha": "HEAD",
"source_branch_sha": "ABCD",
"target_branch_sha": "DCBA",
"merge_params": { "merge_params": {
"force_remove_source_branch": null "force_remove_source_branch": null
}, },
......
...@@ -10,6 +10,10 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do ...@@ -10,6 +10,10 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
@shared = Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path') @shared = Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path')
allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/') allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/')
@project = create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project') @project = create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project')
allow(@project.repository).to receive(:fetch_ref).and_return(true)
expect(@project.repository).to receive(:create_branch).with('feature', 'DCBA')
project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project) project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
@restored_project_json = project_tree_restorer.restore @restored_project_json = project_tree_restorer.restore
end end
......
...@@ -11,6 +11,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver do ...@@ -11,6 +11,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
before do before do
project.team << [user, :master] project.team << [user, :master]
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
allow_any_instance_of(MergeRequest).to receive(:source_branch_sha).and_return('ABCD')
allow_any_instance_of(MergeRequest).to receive(:target_branch_sha).and_return('DCBA')
end end
after do after do
...@@ -43,6 +45,14 @@ describe Gitlab::ImportExport::ProjectTreeSaver do ...@@ -43,6 +45,14 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
expect(saved_project_json['merge_requests'].first['milestone']).not_to be_empty expect(saved_project_json['merge_requests'].first['milestone']).not_to be_empty
end end
it 'has merge request\'s source branch SHA' do
expect(saved_project_json['merge_requests'].first['source_branch_sha']).to eq('ABCD')
end
it 'has merge request\'s target branch SHA' do
expect(saved_project_json['merge_requests'].first['target_branch_sha']).to eq('DCBA')
end
it 'has events' do it 'has events' do
expect(saved_project_json['merge_requests'].first['milestone']['events']).not_to be_empty expect(saved_project_json['merge_requests'].first['milestone']['events']).not_to be_empty
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