diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 17:34:42 +0300 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /lib/gitlab/diff | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'lib/gitlab/diff')
-rw-r--r-- | lib/gitlab/diff/file.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/diff/formatters/text_formatter.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/diff/highlight_cache.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/diff/position.rb | 2 |
4 files changed, 20 insertions, 4 deletions
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index 4fc5bfddf0c..d1398ddb642 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -314,6 +314,10 @@ module Gitlab @rich_viewer = rich_viewer_class&.new(self) end + def alternate_viewer + alternate_viewer_class&.new(self) + end + def rendered_as_text?(ignore_errors: true) simple_viewer.is_a?(DiffViewer::Text) && (ignore_errors || simple_viewer.render_error.nil?) end @@ -353,7 +357,7 @@ module Gitlab def fetch_blob(sha, path) return unless sha - Blob.lazy(repository.project, sha, path) + Blob.lazy(repository, sha, path) end def total_blob_lines(blob) @@ -419,6 +423,17 @@ module Gitlab return if collapsed? return unless diffable? return unless modified_file? + + find_renderable_viewer_class(classes) + end + + def alternate_viewer_class + return unless viewer.class == DiffViewer::Renamed + + find_renderable_viewer_class(RICH_VIEWERS) || (DiffViewer::Text if text?) + end + + def find_renderable_viewer_class(classes) return if different_type? || external_storage_error? verify_binary = !stored_externally? diff --git a/lib/gitlab/diff/formatters/text_formatter.rb b/lib/gitlab/diff/formatters/text_formatter.rb index 728457b3139..9ea9bdfdf15 100644 --- a/lib/gitlab/diff/formatters/text_formatter.rb +++ b/lib/gitlab/diff/formatters/text_formatter.rb @@ -45,7 +45,8 @@ module Gitlab def ==(other) other.is_a?(self.class) && new_line == other.new_line && - old_line == other.old_line + old_line == other.old_line && + line_range == other.line_range end end end diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb index 01ec9798fe4..ccf09b37b9b 100644 --- a/lib/gitlab/diff/highlight_cache.rb +++ b/lib/gitlab/diff/highlight_cache.rb @@ -156,7 +156,7 @@ module Gitlab end results.map! do |result| - JSON.parse(extract_data(result), symbolize_names: true) unless result.nil? + Gitlab::Json.parse(extract_data(result), symbolize_names: true) unless result.nil? end file_paths.zip(results).to_h diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb index 8b99fd5cd42..10ad23b7774 100644 --- a/lib/gitlab/diff/position.rb +++ b/lib/gitlab/diff/position.rb @@ -68,7 +68,7 @@ module Gitlab end def to_json(opts = nil) - JSON.generate(formatter.to_h, opts) + Gitlab::Json.generate(formatter.to_h, opts) end def as_json(opts = nil) |