diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 12:08:42 +0300 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /lib/gitlab/conflict | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/conflict')
-rw-r--r-- | lib/gitlab/conflict/file.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/conflict/file_collection.rb | 4 |
2 files changed, 23 insertions, 3 deletions
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb index fbf021345ca..d40a6323d4f 100644 --- a/lib/gitlab/conflict/file.rb +++ b/lib/gitlab/conflict/file.rb @@ -23,7 +23,7 @@ module Gitlab # 'raw' holds the Gitlab::Git::Conflict::File that this instance wraps attr_reader :raw - delegate :type, :content, :their_path, :our_path, :our_mode, :our_blob, :repository, to: :raw + delegate :type, :content, :path, :ancestor_path, :their_path, :our_path, :our_mode, :our_blob, :repository, to: :raw def initialize(raw, merge_request:) @raw = raw @@ -227,6 +227,26 @@ module Gitlab new_path: our_path) end + def conflict_type(diff_file) + if ancestor_path.present? + if our_path.present? && their_path.present? + :both_modified + elsif their_path.blank? + :modified_source_removed_target + else + :modified_target_removed_source + end + else + if our_path.present? && their_path.present? + :both_added + elsif their_path.blank? + diff_file.renamed_file? ? :renamed_same_file : :removed_target_renamed_source + else + :removed_source_renamed_target + end + end + end + private def map_raw_lines(raw_lines) diff --git a/lib/gitlab/conflict/file_collection.rb b/lib/gitlab/conflict/file_collection.rb index 047600af267..c4ee1dafe20 100644 --- a/lib/gitlab/conflict/file_collection.rb +++ b/lib/gitlab/conflict/file_collection.rb @@ -7,14 +7,14 @@ module Gitlab attr_reader :merge_request, :resolver - def initialize(merge_request) + def initialize(merge_request, allow_tree_conflicts: false) our_commit = merge_request.source_branch_head.raw their_commit = merge_request.target_branch_head.raw @target_repo = merge_request.target_project.repository @source_repo = merge_request.source_project.repository.raw @our_commit_id = our_commit.id @their_commit_id = their_commit.id - @resolver = Gitlab::Git::Conflict::Resolver.new(@target_repo.raw, @our_commit_id, @their_commit_id) + @resolver = Gitlab::Git::Conflict::Resolver.new(@target_repo.raw, @our_commit_id, @their_commit_id, allow_tree_conflicts: allow_tree_conflicts) @merge_request = merge_request end |