Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-21 06:08:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-21 06:08:34 +0300
commit9c1df7bcf10e362442057b1df43a753b621d85ee (patch)
tree593887914bd382186b016387d6dbde6c21c03d08 /lib/gitlab/diff
parent92ea86691a2a6b3df4b36c7ff00001410303a701 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/file_collection/base.rb16
-rw-r--r--lib/gitlab/diff/formatters/base_formatter.rb11
-rw-r--r--lib/gitlab/diff/position.rb7
-rw-r--r--lib/gitlab/diff/position_tracer/image_strategy.rb9
-rw-r--r--lib/gitlab/diff/position_tracer/line_strategy.rb30
5 files changed, 18 insertions, 55 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index 7fa1bd6b5ec..924de132840 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -68,20 +68,12 @@ module Gitlab
end
end
- def diff_file_with_old_path(old_path, a_mode = nil)
- if Feature.enabled?(:file_identifier_hash) && a_mode.present?
- diff_files.find { |diff_file| diff_file.old_path == old_path && diff_file.a_mode == a_mode }
- else
- diff_files.find { |diff_file| diff_file.old_path == old_path }
- end
+ def diff_file_with_old_path(old_path)
+ diff_files.find { |diff_file| diff_file.old_path == old_path }
end
- def diff_file_with_new_path(new_path, b_mode = nil)
- if Feature.enabled?(:file_identifier_hash) && b_mode.present?
- diff_files.find { |diff_file| diff_file.new_path == new_path && diff_file.b_mode == b_mode }
- else
- diff_files.find { |diff_file| diff_file.new_path == new_path }
- end
+ def diff_file_with_new_path(new_path)
+ diff_files.find { |diff_file| diff_file.new_path == new_path }
end
def clear_cache
diff --git a/lib/gitlab/diff/formatters/base_formatter.rb b/lib/gitlab/diff/formatters/base_formatter.rb
index e24150a2330..19fc028594c 100644
--- a/lib/gitlab/diff/formatters/base_formatter.rb
+++ b/lib/gitlab/diff/formatters/base_formatter.rb
@@ -6,7 +6,6 @@ module Gitlab
class BaseFormatter
attr_reader :old_path
attr_reader :new_path
- attr_reader :file_identifier_hash
attr_reader :base_sha
attr_reader :start_sha
attr_reader :head_sha
@@ -16,7 +15,6 @@ module Gitlab
attrs[:diff_refs] = diff_file.diff_refs
attrs[:old_path] = diff_file.old_path
attrs[:new_path] = diff_file.new_path
- attrs[:file_identifier_hash] = diff_file.file_identifier_hash
end
if diff_refs = attrs[:diff_refs]
@@ -27,7 +25,6 @@ module Gitlab
@old_path = attrs[:old_path]
@new_path = attrs[:new_path]
- @file_identifier_hash = attrs[:file_identifier_hash]
@base_sha = attrs[:base_sha]
@start_sha = attrs[:start_sha]
@head_sha = attrs[:head_sha]
@@ -38,7 +35,7 @@ module Gitlab
end
def to_h
- out = {
+ {
base_sha: base_sha,
start_sha: start_sha,
head_sha: head_sha,
@@ -46,12 +43,6 @@ module Gitlab
new_path: new_path,
position_type: position_type
}
-
- if Feature.enabled?(:file_identifier_hash)
- out[:file_identifier_hash] = file_identifier_hash
- end
-
- out
end
def position_type
diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb
index 74c33c46598..40b6ae2f14e 100644
--- a/lib/gitlab/diff/position.rb
+++ b/lib/gitlab/diff/position.rb
@@ -9,7 +9,6 @@ module Gitlab
delegate :old_path,
:new_path,
- :file_identifier_hash,
:base_sha,
:start_sha,
:head_sha,
@@ -161,11 +160,7 @@ module Gitlab
def find_diff_file_from(diffable)
diff_files = diffable.diffs(diff_options).diff_files
- if Feature.enabled?(:file_identifier_hash) && file_identifier_hash.present?
- diff_files.find { |df| df.file_identifier_hash == file_identifier_hash }
- else
- diff_files.first
- end
+ diff_files.first
end
def multiline?
diff --git a/lib/gitlab/diff/position_tracer/image_strategy.rb b/lib/gitlab/diff/position_tracer/image_strategy.rb
index 046a6782dda..aac52b536f7 100644
--- a/lib/gitlab/diff/position_tracer/image_strategy.rb
+++ b/lib/gitlab/diff/position_tracer/image_strategy.rb
@@ -7,24 +7,21 @@ module Gitlab
def trace(position)
a_path = position.old_path
b_path = position.new_path
- diff_file = diff_file(position)
- a_mode = diff_file&.a_mode
- b_mode = diff_file&.b_mode
# If file exists in B->D (e.g. updated, renamed, removed), let the
# note become outdated.
- bd_diff = bd_diffs.diff_file_with_old_path(b_path, b_mode)
+ bd_diff = bd_diffs.diff_file_with_old_path(b_path)
return { position: new_position(position, bd_diff), outdated: true } if bd_diff
# If file still exists in the new diff, update the position.
- cd_diff = cd_diffs.diff_file_with_new_path(b_path, b_mode)
+ cd_diff = cd_diffs.diff_file_with_new_path(b_path)
return { position: new_position(position, cd_diff), outdated: false } if cd_diff
# If file exists in A->C (e.g. rebased and same changes were present
# in target branch), let the note become outdated.
- ac_diff = ac_diffs.diff_file_with_old_path(a_path, a_mode)
+ ac_diff = ac_diffs.diff_file_with_old_path(a_path)
return { position: new_position(position, ac_diff), outdated: true } if ac_diff
diff --git a/lib/gitlab/diff/position_tracer/line_strategy.rb b/lib/gitlab/diff/position_tracer/line_strategy.rb
index 0f0b8f0c4f3..d7a7e3f5425 100644
--- a/lib/gitlab/diff/position_tracer/line_strategy.rb
+++ b/lib/gitlab/diff/position_tracer/line_strategy.rb
@@ -76,20 +76,16 @@ module Gitlab
def trace_added_line(position)
b_path = position.new_path
b_line = position.new_line
- diff_file = diff_file(position)
- b_mode = diff_file&.b_mode
- bd_diff = bd_diffs.diff_file_with_old_path(b_path, b_mode)
+ bd_diff = bd_diffs.diff_file_with_old_path(b_path)
d_path = bd_diff&.new_path || b_path
- d_mode = bd_diff&.b_mode || b_mode
d_line = LineMapper.new(bd_diff).old_to_new(b_line)
if d_line
- cd_diff = cd_diffs.diff_file_with_new_path(d_path, d_mode)
+ cd_diff = cd_diffs.diff_file_with_new_path(d_path)
c_path = cd_diff&.old_path || d_path
- c_mode = cd_diff&.a_mode || d_mode
c_line = LineMapper.new(cd_diff).new_to_old(d_line)
if c_line
@@ -102,7 +98,7 @@ module Gitlab
else
# If the line is no longer in the MR, we unfortunately cannot show
# the current state on the CD diff, so we treat it as outdated.
- ac_diff = ac_diffs.diff_file_with_new_path(c_path, c_mode)
+ ac_diff = ac_diffs.diff_file_with_new_path(c_path)
{ position: new_position(ac_diff, nil, c_line, position.line_range), outdated: true }
end
@@ -119,26 +115,22 @@ module Gitlab
def trace_removed_line(position)
a_path = position.old_path
a_line = position.old_line
- diff_file = diff_file(position)
- a_mode = diff_file&.a_mode
- ac_diff = ac_diffs.diff_file_with_old_path(a_path, a_mode)
+ ac_diff = ac_diffs.diff_file_with_old_path(a_path)
c_path = ac_diff&.new_path || a_path
- c_mode = ac_diff&.b_mode || a_mode
c_line = LineMapper.new(ac_diff).old_to_new(a_line)
if c_line
- cd_diff = cd_diffs.diff_file_with_old_path(c_path, c_mode)
+ cd_diff = cd_diffs.diff_file_with_old_path(c_path)
d_path = cd_diff&.new_path || c_path
- d_mode = cd_diff&.b_mode || c_mode
d_line = LineMapper.new(cd_diff).old_to_new(c_line)
if d_line
# If the line is still in C but also in D, it has turned from a
# removed line into an unchanged one.
- bd_diff = bd_diffs.diff_file_with_new_path(d_path, d_mode)
+ bd_diff = bd_diffs.diff_file_with_new_path(d_path)
{ position: new_position(bd_diff, nil, d_line, position.line_range), outdated: true }
else
@@ -156,21 +148,17 @@ module Gitlab
a_line = position.old_line
b_path = position.new_path
b_line = position.new_line
- diff_file = diff_file(position)
- a_mode = diff_file&.a_mode
- b_mode = diff_file&.b_mode
- ac_diff = ac_diffs.diff_file_with_old_path(a_path, a_mode)
+ ac_diff = ac_diffs.diff_file_with_old_path(a_path)
c_path = ac_diff&.new_path || a_path
- c_mode = ac_diff&.b_mode || a_mode
c_line = LineMapper.new(ac_diff).old_to_new(a_line)
- bd_diff = bd_diffs.diff_file_with_old_path(b_path, b_mode)
+ bd_diff = bd_diffs.diff_file_with_old_path(b_path)
d_line = LineMapper.new(bd_diff).old_to_new(b_line)
- cd_diff = cd_diffs.diff_file_with_old_path(c_path, c_mode)
+ cd_diff = cd_diffs.diff_file_with_old_path(c_path)
if c_line && d_line
# If the line is still in C and D, it is still unchanged.