diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-27 19:00:34 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-03 07:00:20 +0200 |
commit | c86c1905b5574cac234315598d8d715fcaee3ea7 (patch) | |
tree | 31ba7ab51c04b07ea70d15db88f2370f9ca6359e /lib/gitlab/diff/file_collection/base.rb | |
parent | 1d0c7b74920a94e488e6a2c090abb3e525438053 (diff) | |
download | gitlab-ce-c86c1905b5574cac234315598d8d715fcaee3ea7.tar.gz |
switch from diff_file_collection to diffs20034-safe-diffs
So we have raw_diffs too
Diffstat (limited to 'lib/gitlab/diff/file_collection/base.rb')
-rw-r--r-- | lib/gitlab/diff/file_collection/base.rb | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb index a0c88265c45..2b9fc65b985 100644 --- a/lib/gitlab/diff/file_collection/base.rb +++ b/lib/gitlab/diff/file_collection/base.rb @@ -1,28 +1,33 @@ module Gitlab module Diff module FileCollection - class Base attr_reader :project, :diff_options, :diff_view, :diff_refs delegate :count, :size, :real_size, to: :diff_files - def initialize(diffs, project:, diff_options: nil, diff_refs: nil) - @diffs = diffs + def self.default_options + ::Commit.max_diff_options.merge(ignore_whitespace_change: false, no_collapse: false) + end + + def initialize(diffable, project:, diff_options: nil, diff_refs: nil) + diff_options = self.class.default_options.merge(diff_options || {}) + + @diffable = diffable + @diffs = diffable.raw_diffs(diff_options) @project = project @diff_options = diff_options @diff_refs = diff_refs end def diff_files - @diffs.decorate! { |diff| decorate_diff!(diff) } + @diff_files ||= @diffs.decorate! { |diff| decorate_diff!(diff) } end private def decorate_diff!(diff) - return diff if diff.is_a?(Gitlab::Diff::File) - Gitlab::Diff::File.new(diff, diff_refs: @diff_refs, repository: @project.repository) + Gitlab::Diff::File.new(diff, repository: project.repository, diff_refs: diff_refs) end end end |