Class: GitHealthCheck::History
- Inherits:
-
Object
- Object
- GitHealthCheck::History
- Defined in:
- lib/git-health-check/history.rb
Constant Summary collapse
- MEGABYTE =
1024 ** 2
Instance Method Summary collapse
-
#initialize(options) ⇒ History
constructor
A new instance of History.
- #search ⇒ Object
Constructor Details
#initialize(options) ⇒ History
Returns a new instance of History.
10 11 12 13 14 |
# File 'lib/git-health-check/history.rb', line 10 def initialize() @repository = [:repository] @bytes_threshold = [:threshold].to_f * MEGABYTE @git_lib = GitHealthCheck::GitLib.new end |
Instance Method Details
#search ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/git-health-check/history.rb', line 16 def search revision_list = @git_lib.get_revision_list.split "\n" big_files = {} revision_list.each do |commit| @git_lib.get_treeish_contents(commit).split("\0").each do |object| bits, type, sha, size, path = object.split next if File.exist?("#@repository/#{path}") size = size.to_f big_files[path] = [sha, size, commit] if size >= @bytes_threshold end end big_files = big_files.map do |path, (sha, size, commit_sha)| where = @git_lib.get_commit_details commit_sha who = @git_lib. commit_sha [sha, (size / MEGABYTE).round(2), path, where, who] end big_files.sort_by! { |a| [a[1], a[2]] }.reverse! end |