diff options
author | Sean McGivern <sean@gitlab.com> | 2017-05-11 16:23:02 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-05-12 20:47:51 +0100 |
commit | ad2bfeb85756db8c4cea9290be743665efd1c918 (patch) | |
tree | cf51b926c348db7a7f5df26117a692f55416fe25 /app/models/merge_request.rb | |
parent | aec53bab05afd0a20b15bd9311643f8bf5efd140 (diff) | |
download | gitlab-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 'app/models/merge_request.rb')
-rw-r--r-- | app/models/merge_request.rb | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 59736f70f24..5f65636ba63 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -899,34 +899,6 @@ class MergeRequest < ActiveRecord::Base project.repository.keep_around(self.merge_commit_sha) end - 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? - - 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 - def has_commits? merge_request_diff && commits_count > 0 end |