summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2017-05-19 08:16:56 -0500
committerDouwe Maan <douwe@selenight.nl>2017-05-19 08:16:56 -0500
commitc215461cfc2923c9db2bf9794e7954fcf343e6c9 (patch)
treef26830bcf340b08fc64cebbe6aed4225d2807e82
parentfdc7d7039b83c2d9b3578338408ce28c6423a483 (diff)
downloadgitlab-ce-9-2-stable-fix-conflicts-for-mr-11298.tar.gz
Fix 9.2 conflicts for 'Fix conflict resolution from corrupted upstream'9-2-stable-fix-conflicts-for-mr-11298
-rw-r--r--app/models/merge_request.rb32
-rw-r--r--app/services/merge_requests/conflicts/list_service.rb1
-rw-r--r--spec/models/merge_request_spec.rb75
-rw-r--r--spec/services/merge_requests/conflicts/list_service_spec.rb7
4 files changed, 8 insertions, 107 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 417a13da812..f5fdf990907 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -905,38 +905,6 @@ class MergeRequest < ActiveRecord::Base
project.repository.keep_around(self.merge_commit_sha)
end
-<<<<<<< HEAD
- def conflicts
- @conflicts ||= Gitlab::Conflict::FileCollection.new(self)
- end
-
- def conflicts_can_be_resolved_by?(user)
- return false unless source_project
-
- access = ::Gitlab::UserAccess.new(user, project: source_project)
- access.can_push_to_branch?(source_branch)
- end
-
- def conflicts_can_be_resolved_in_ui?
- return @conflicts_can_be_resolved_in_ui if defined?(@conflicts_can_be_resolved_in_ui)
-
- return @conflicts_can_be_resolved_in_ui = false unless cannot_be_merged?
- return @conflicts_can_be_resolved_in_ui = false unless has_complete_diff_refs?
- return @conflicts_can_be_resolved_in_ui = false if branch_missing?
-
- begin
- # Try to parse each conflict. If the MR's mergeable status hasn't been updated,
- # ensure that we don't say there are conflicts to resolve when there are no conflict
- # files.
- conflicts.files.each(&:lines)
- @conflicts_can_be_resolved_in_ui = conflicts.files.length > 0
- rescue Rugged::OdbError, Gitlab::Conflict::Parser::UnresolvableError, Gitlab::Conflict::FileCollection::ConflictSideMissing
- @conflicts_can_be_resolved_in_ui = false
- end
- end
-
-=======
->>>>>>> e4261fe3... Merge branch 'fix-conflict-resolution-with-corrupt-repos' into 'master'
def has_commits?
merge_request_diff && commits_count > 0
end
diff --git a/app/services/merge_requests/conflicts/list_service.rb b/app/services/merge_requests/conflicts/list_service.rb
index 9bf82518643..9835606812c 100644
--- a/app/services/merge_requests/conflicts/list_service.rb
+++ b/app/services/merge_requests/conflicts/list_service.rb
@@ -15,6 +15,7 @@ module MergeRequests
return @conflicts_can_be_resolved_in_ui = false unless merge_request.cannot_be_merged?
return @conflicts_can_be_resolved_in_ui = false unless merge_request.has_complete_diff_refs?
+ return @conflicts_can_be_resolved_in_ui = false if merge_request.branch_missing?
begin
# Try to parse each conflict. If the MR's mergeable status hasn't been
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index bbdf758cc61..096d6d3673f 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1315,81 +1315,6 @@ describe MergeRequest, models: true do
end
end
-<<<<<<< HEAD
- describe '#conflicts_can_be_resolved_in_ui?' do
- def create_merge_request(source_branch)
- create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start') do |mr|
- mr.mark_as_unmergeable
- end
- end
-
- it 'returns a falsey value when the MR can be merged without conflicts' do
- merge_request = create_merge_request('master')
- merge_request.mark_as_mergeable
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the MR is marked as having conflicts, but has none' do
- merge_request = create_merge_request('master')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when one of the MR branches is missing' do
- merge_request = create_merge_request('conflict-resolvable')
- merge_request.project.repository.rm_branch(merge_request.author, 'conflict-resolvable')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the MR has a missing ref after a force push' do
- merge_request = create_merge_request('conflict-resolvable')
- allow(merge_request.conflicts).to receive(:merge_index).and_raise(Rugged::OdbError)
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the MR does not support new diff notes' do
- merge_request = create_merge_request('conflict-resolvable')
- merge_request.merge_request_diff.update_attributes(start_commit_sha: nil)
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the conflicts contain a large file' do
- merge_request = create_merge_request('conflict-too-large')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the conflicts contain a binary file' do
- merge_request = create_merge_request('conflict-binary-file')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a falsey value when the conflicts contain a file edited in one branch and deleted in another' do
- merge_request = create_merge_request('conflict-missing-side')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_falsey
- end
-
- it 'returns a truthy value when the conflicts are resolvable in the UI' do
- merge_request = create_merge_request('conflict-resolvable')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_truthy
- end
-
- it 'returns a truthy value when the conflicts have to be resolved in an editor' do
- merge_request = create_merge_request('conflict-contains-conflict-markers')
-
- expect(merge_request.conflicts_can_be_resolved_in_ui?).to be_truthy
- end
- end
-
-=======
->>>>>>> e4261fe3... Merge branch 'fix-conflict-resolution-with-corrupt-repos' into 'master'
describe "#source_project_missing?" do
let(:project) { create(:empty_project) }
let(:fork_project) { create(:empty_project, forked_from_project: project) }
diff --git a/spec/services/merge_requests/conflicts/list_service_spec.rb b/spec/services/merge_requests/conflicts/list_service_spec.rb
index e8a305d6130..23982b9e6e1 100644
--- a/spec/services/merge_requests/conflicts/list_service_spec.rb
+++ b/spec/services/merge_requests/conflicts/list_service_spec.rb
@@ -25,6 +25,13 @@ describe MergeRequests::Conflicts::ListService do
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
+ it 'returns a falsey value when one of the MR branches is missing' do
+ merge_request = create_merge_request('conflict-resolvable')
+ merge_request.project.repository.rm_branch(merge_request.author, 'conflict-resolvable')
+
+ expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
+ end
+
it 'returns a falsey value when the MR has a missing ref after a force push' do
merge_request = create_merge_request('conflict-resolvable')
service = conflicts_service(merge_request)