2016-07-26 03:21:42 -04:00
|
|
|
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
|
|
|
|
|
2016-07-27 13:00:34 -04:00
|
|
|
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)
|
2016-07-26 03:21:42 -04:00
|
|
|
@project = project
|
|
|
|
@diff_options = diff_options
|
|
|
|
@diff_refs = diff_refs
|
|
|
|
end
|
|
|
|
|
|
|
|
def diff_files
|
2016-07-27 13:00:34 -04:00
|
|
|
@diff_files ||= @diffs.decorate! { |diff| decorate_diff!(diff) }
|
2016-07-26 03:21:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def decorate_diff!(diff)
|
2016-07-27 13:00:34 -04:00
|
|
|
Gitlab::Diff::File.new(diff, repository: project.repository, diff_refs: diff_refs)
|
2016-07-26 03:21:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|