summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/merge_requests_controller_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-05-11 16:23:02 +0100
committerSean McGivern <sean@gitlab.com>2017-05-12 20:47:51 +0100
commitad2bfeb85756db8c4cea9290be743665efd1c918 (patch)
treecf51b926c348db7a7f5df26117a692f55416fe25 /spec/controllers/projects/merge_requests_controller_spec.rb
parentaec53bab05afd0a20b15bd9311643f8bf5efd140 (diff)
downloadgitlab-ce-ad2bfeb85756db8c4cea9290be743665efd1c918.tar.gz
Fix conflict resolution from corrupted upstreamfix-conflict-resolution-with-corrupt-repos
I don't know why this happens exactly, but given an upstream and fork repository from a customer, both of which required GC, resolving conflicts would corrupt the fork so badly that it couldn't be cloned. This isn't a perfect fix for that case, because the MR may still need to be merged manually, but it does ensure that the repository is at least usable. My best guess is that when we generate the index for the conflict resolution (which we previously did in the target project), we obtain a reference to an OID that doesn't exist in the source, even though we already fetch the refs from the target into the source. Explicitly setting the source project as the place to get the merge index from seems to prevent repository corruption in this way.
Diffstat (limited to 'spec/controllers/projects/merge_requests_controller_spec.rb')
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 37a253fde9b..0b3492a8fed 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -916,7 +916,9 @@ describe Projects::MergeRequestsController do
end
it 'returns the file in JSON format' do
- content = merge_request_with_conflicts.conflicts.file_for_path(path, path).content
+ content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts).
+ file_for_path(path, path).
+ content
expect(json_response).to include('old_path' => path,
'new_path' => path,
@@ -1040,11 +1042,15 @@ describe Projects::MergeRequestsController do
context 'when a file has identical content to the conflict' do
before do
+ content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts).
+ file_for_path('files/ruby/popen.rb', 'files/ruby/popen.rb').
+ content
+
resolved_files = [
{
'new_path' => 'files/ruby/popen.rb',
'old_path' => 'files/ruby/popen.rb',
- 'content' => merge_request_with_conflicts.conflicts.file_for_path('files/ruby/popen.rb', 'files/ruby/popen.rb').content
+ 'content' => content
}, {
'new_path' => 'files/ruby/regex.rb',
'old_path' => 'files/ruby/regex.rb',