debian-mirror-gitlab/lib/gitlab/git/diff_stats_collection.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
783 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
module Gitlab
module Git
class DiffStatsCollection
include Gitlab::Utils::StrongMemoize
include Enumerable
def initialize(diff_stats)
@collection = diff_stats
end
def each(&block)
@collection.each(&block)
end
def find_by_path(path)
indexed_by_path[path]
end
def paths
@collection.map(&:path)
end
2022-01-26 12:08:38 +05:30
def real_size
max_files = ::Commit.diff_max_files
2020-04-22 19:07:51 +05:30
if paths.size > max_files
"#{max_files}+"
else
paths.size.to_s
end
end
2018-12-05 23:21:45 +05:30
private
def indexed_by_path
strong_memoize(:indexed_by_path) do
index_by { |stats| stats.path }
end
end
end
end
end