BigW Consortium Gitlab

Commit ce89c425 by Sean McGivern

Merge branch 'fix/import-fork-mr' into 'master'

Fix Import/Export issue to do with fork merge requests Closes #36666 See merge request !13717
parents e6f20e52 e163c83b
---
title: Fix Import/Export issue to do with fork merge requests
merge_request:
author:
type: fixed
......@@ -134,5 +134,7 @@ methods:
- :utf8_diff
merge_requests:
- :diff_head_sha
- :source_branch_sha
- :target_branch_sha
project:
- :description_html
......@@ -30,7 +30,7 @@ module Gitlab
end
def branch_exists?(branch_name)
@project.repository.branch_exists?(branch_name)
@project.repository.raw.branch_exists?(branch_name)
end
def fork_merge_request?
......
......@@ -2522,7 +2522,7 @@
"id": 27,
"target_branch": "feature",
"source_branch": "feature_conflict",
"source_project_id": 5,
"source_project_id": 999,
"author_id": 1,
"assignee_id": null,
"title": "MR1",
......@@ -2536,6 +2536,9 @@
"position": 0,
"updated_by_id": null,
"merge_error": null,
"diff_head_sha": "HEAD",
"source_branch_sha": "ABCD",
"target_branch_sha": "DCBA",
"merge_params": {
"force_remove_source_branch": null
},
......
......@@ -10,6 +10,13 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
@shared = Gitlab::ImportExport::Shared.new(relative_path: "", project_path: 'path')
allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/')
@project = create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project')
allow(@project.repository).to receive(:fetch_ref).and_return(true)
allow(@project.repository.raw).to receive(:rugged_branch_exists?).and_return(false)
expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA')
allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch)
project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
@restored_project_json = project_tree_restorer.restore
end
......
......@@ -11,6 +11,8 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
before do
project.team << [user, :master]
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
after do
......@@ -43,6 +45,14 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
expect(saved_project_json['merge_requests'].first['milestone']).not_to be_empty
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
expect(saved_project_json['merge_requests'].first['milestone']['events']).not_to be_empty
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