commits_period method

This commit is contained in:
Tomasz Gieniusz 2012-10-19 22:01:01 +02:00
parent 636b9bc345
commit cf27a2967b
3 changed files with 11 additions and 3 deletions

View file

@ -32,6 +32,10 @@ module GitStats
end.sort_by! { |e| e.date }.extend(ByFieldFinder)
end
def commits_period
commits.map(&:date).minmax
end
def last_commit
commits.last
end

View file

@ -10,6 +10,10 @@ describe GitStats::GitData::Repo do
]
end
it 'should calculate correct commits period' do
repo.commits_period.should == [DateTime.parse('2012-10-19 10:44:34 +0200'), DateTime.parse('2012-10-26 17:05:25 +0200')]
end
it 'should gather all commits sorted by date' do
repo.commits.map(&:hash).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d fd66657 81e8bef 4e7d0e9 872955c)
end

View file

@ -13,13 +13,13 @@
%td= "GitStats #{GitStats::VERSION}"
%tr
%td Report period
%td= repo.commits.map(&:date).minmax.map {|d| d.to_formatted_s(:long)}.join(" .. ")
%td= repo.commits_period.map {|d| d.to_formatted_s(:long)}.join(" .. ")
%tr
%td Total files
%td= repo.commits.last.files_count
%td= repo.files_count
%tr
%td Total lines
%td= "#{repo.commits.last.lines_count} lines (#{repo.short_stats.map(&:insertions).sum} insertions, #{repo.short_stats.map(&:deletions).sum} deletions)"
%td= "#{repo.lines_count} lines (#{repo.short_stats.map(&:insertions).sum} insertions, #{repo.short_stats.map(&:deletions).sum} deletions)"
%tr
%td Total commits
%td= repo.commits.size