Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base.rb « file_collection « diff « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 20562773c14afc176b0219c013493dd32af07009 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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:, diff_refs: nil)
          @diffs        = diffs
          @project      = project
          @diff_options = diff_options
          @diff_refs    = diff_refs
        end

        def 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)
        end
      end
    end
  end
end