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>2019-12-11 18:07:38 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-11 18:07:38 +0300
commit4eea104c69e59f6fa53c7bc15b986c69f29b60c8 (patch)
tree2eff1ce7ac4a58de15b1f5980acfdb22c7b92ac0 /lib/gitlab/diff
parentb86f474bf51e20d2db4cf0895d0a8e0894e31c08 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r--lib/gitlab/diff/file_collection/base.rb12
-rw-r--r--lib/gitlab/diff/file_collection/merge_request_diff_batch.rb4
-rw-r--r--lib/gitlab/diff/highlight_cache.rb2
-rw-r--r--lib/gitlab/diff/line.rb8
4 files changed, 21 insertions, 5 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index c5bbf522f7c..ea915a6b84b 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -34,6 +34,18 @@ module Gitlab
@diff_files ||= diffs.decorate! { |diff| decorate_diff!(diff) }
end
+ def diff_file_paths
+ diff_files.map(&:file_path)
+ end
+
+ def pagination_data
+ {
+ current_page: nil,
+ next_page: nil,
+ total_pages: nil
+ }
+ end
+
# This mutates `diff_files` lines.
def unfold_diff_files(positions)
positions_grouped_by_path = positions.group_by { |position| position.file_path }
diff --git a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
index 663326e01d5..c6d1e0b93a7 100644
--- a/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
+++ b/lib/gitlab/diff/file_collection/merge_request_diff_batch.rb
@@ -29,10 +29,6 @@ module Gitlab
}
end
- def diff_file_paths
- diff_files.map(&:file_path)
- end
-
override :diffs
def diffs
strong_memoize(:diffs) do
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb
index bc1baa09d39..10363236234 100644
--- a/lib/gitlab/diff/highlight_cache.rb
+++ b/lib/gitlab/diff/highlight_cache.rb
@@ -21,7 +21,7 @@ module Gitlab
def decorate(diff_file)
if content = read_file(diff_file)
diff_file.highlighted_diff_lines = content.map do |line|
- Gitlab::Diff::Line.init_from_hash(line)
+ Gitlab::Diff::Line.safe_init_from_hash(line)
end
end
end
diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb
index 28ea1921f90..379fc6af875 100644
--- a/lib/gitlab/diff/line.rb
+++ b/lib/gitlab/diff/line.rb
@@ -34,6 +34,14 @@ module Gitlab
rich_text: hash[:rich_text])
end
+ def self.safe_init_from_hash(hash)
+ line = hash.with_indifferent_access
+ rich_text = line[:rich_text]
+ line[:rich_text] = rich_text&.html_safe
+
+ init_from_hash(line)
+ end
+
def to_hash
hash = {}
SERIALIZE_KEYS.each { |key| hash[key] = send(key) } # rubocop:disable GitlabSecurity/PublicSend