mirror of
https://github.com/tomgi/git_stats.git
synced 2024-12-22 13:32:17 +01:00
commits_period method
This commit is contained in:
parent
636b9bc345
commit
cf27a2967b
3 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue