debian-mirror-gitlab/lib/gitlab/diff/file_collection/merge_request_diff.rb

54 lines
1.1 KiB
Ruby
Raw Normal View History

2019-02-13 22:33:31 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module Gitlab
module Diff
module FileCollection
2016-09-29 09:46:39 +05:30
class MergeRequestDiff < Base
2018-11-20 20:47:30 +05:30
extend ::Gitlab::Utils::Override
2016-09-29 09:46:39 +05:30
def initialize(merge_request_diff, diff_options:)
@merge_request_diff = merge_request_diff
2016-09-13 17:45:13 +05:30
2016-09-29 09:46:39 +05:30
super(merge_request_diff,
project: merge_request_diff.project,
2016-09-13 17:45:13 +05:30
diff_options: diff_options,
2017-09-10 17:25:29 +05:30
diff_refs: merge_request_diff.diff_refs,
fallback_diff_refs: merge_request_diff.fallback_diff_refs)
2016-09-13 17:45:13 +05:30
end
def diff_files
2018-03-27 19:54:05 +05:30
diff_files = super
2018-11-20 20:47:30 +05:30
diff_files.each { |diff_file| cache.decorate(diff_file) }
2018-03-27 19:54:05 +05:30
diff_files
2016-09-13 17:45:13 +05:30
end
2018-11-20 20:47:30 +05:30
override :write_cache
def write_cache
cache.write_if_empty
2017-08-17 22:00:37 +05:30
end
2018-11-20 20:47:30 +05:30
override :clear_cache
def clear_cache
cache.clear
2018-05-09 12:01:36 +05:30
end
def cache_key
2018-11-20 20:47:30 +05:30
cache.key
2016-09-13 17:45:13 +05:30
end
2018-11-20 20:47:30 +05:30
def real_size
@merge_request_diff.real_size
2016-09-13 17:45:13 +05:30
end
2018-11-20 20:47:30 +05:30
private
2016-09-13 17:45:13 +05:30
2018-11-20 20:47:30 +05:30
def cache
@cache ||= Gitlab::Diff::HighlightCache.new(self)
2016-09-13 17:45:13 +05:30
end
end
end
end
end