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/git/conflict/file.rb | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'lib/gitlab/git/conflict/file.rb')
-rw-r--r-- | lib/gitlab/git/conflict/file.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/gitlab/git/conflict/file.rb b/lib/gitlab/git/conflict/file.rb index 7ffe4a7ae81..049ca5a54b3 100644 --- a/lib/gitlab/git/conflict/file.rb +++ b/lib/gitlab/git/conflict/file.rb @@ -6,13 +6,14 @@ module Gitlab class File UnsupportedEncoding = Class.new(StandardError) - attr_reader :their_path, :our_path, :our_mode, :repository, :commit_oid + attr_reader :ancestor_path, :their_path, :our_path, :our_mode, :repository, :commit_oid attr_accessor :raw_content def initialize(repository, commit_oid, conflict, raw_content) @repository = repository @commit_oid = commit_oid + @ancestor_path = conflict[:ancestor][:path] @their_path = conflict[:theirs][:path] @our_path = conflict[:ours][:path] @our_mode = conflict[:ours][:mode] @@ -94,6 +95,15 @@ module Gitlab resolution end + + def path + # There are conflict scenarios (e.g. file is removed on source) wherein + # our_path will be blank/nil. Since we are indexing them by path in + # `#conflicts` helper and we want to match the diff file to a conflict + # in `DiffFileEntity#highlighted_diff_lines`, we need to fallback to + # their_path (this is the path on target). + our_path.presence || their_path + end end end end |