git_stats 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/README.md +16 -10
  4. data/config/locales/de.yml +2 -0
  5. data/config/locales/en.yml +4 -1
  6. data/lib/git_stats/base.rb +3 -1
  7. data/lib/git_stats/cli.rb +5 -3
  8. data/lib/git_stats/core_extensions/enumerable.rb +10 -0
  9. data/lib/git_stats/generator.rb +4 -4
  10. data/lib/git_stats/git_data/comment_stat.rb +38 -0
  11. data/lib/git_stats/git_data/commit.rb +8 -4
  12. data/lib/git_stats/git_data/repo.rb +46 -13
  13. data/lib/git_stats/git_data/short_stat.rb +1 -1
  14. data/lib/git_stats/git_data/tree.rb +23 -0
  15. data/lib/git_stats/i18n.rb +1 -0
  16. data/lib/git_stats/stats_view/charts/authors_charts.rb +6 -4
  17. data/lib/git_stats/stats_view/charts/charts.rb +1 -1
  18. data/lib/git_stats/stats_view/charts/repo_charts.rb +10 -0
  19. data/lib/git_stats/stats_view/view.rb +2 -1
  20. data/lib/git_stats/version.rb +1 -1
  21. data/spec/factories.rb +8 -0
  22. data/spec/git_data/commit_range_spec.rb +2 -2
  23. data/spec/git_data/commit_spec.rb +1 -1
  24. data/spec/git_data/generator_spec.rb +5 -7
  25. data/spec/git_data/repo_spec.rb +5 -5
  26. data/spec/git_data/short_stat_spec.rb +1 -1
  27. data/spec/git_data/tree_spec.rb +41 -0
  28. data/spec/integration/author_spec.rb +2 -2
  29. data/spec/integration/file_spec.rb +2 -2
  30. data/spec/integration/shared.rb +91 -0
  31. data/spec/integration/tree_spec.rb +197 -0
  32. data/templates/author_details/_author_details.haml +4 -4
  33. data/templates/authors/_authors.haml +5 -5
  34. data/templates/comments/_comments.haml +11 -0
  35. data/templates/comments/by_date.haml +1 -0
  36. data/templates/general.haml +3 -0
  37. metadata +31 -25
  38. data/lib/git_stats/by_field_finder.rb +0 -7
  39. data/spec/by_field_finder_spec.rb +0 -25
@@ -55,7 +55,8 @@ module GitStats
55
55
  activity: 'activity/by_date.html',
56
56
  authors: 'authors/best_authors.html',
57
57
  files: 'files/by_date.html',
58
- lines: 'lines/by_date.html'
58
+ lines: 'lines/by_date.html',
59
+ comments: 'comments/by_date.html'
59
60
  }
60
61
  end
61
62
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module GitStats
3
- VERSION = "1.0.11"
3
+ VERSION = "1.0.12"
4
4
  end
@@ -7,6 +7,9 @@ FactoryGirl.define do
7
7
  factory :test_repo do
8
8
  path 'spec/integration/test_repo'
9
9
  end
10
+ factory :test_repo_tree do
11
+ path 'spec/integration/test_repo_tree'
12
+ end
10
13
  end
11
14
 
12
15
  factory :author, class: GitStats::GitData::Author do
@@ -22,4 +25,9 @@ FactoryGirl.define do
22
25
  association :repo, strategy: :build
23
26
  association :author, strategy: :build
24
27
  end
28
+
29
+ factory :tree, class: GitStats::GitData::Tree do
30
+ association :repo, strategy: :build
31
+ end
32
+
25
33
  end
@@ -28,12 +28,12 @@ describe GitStats::GitData::Repo do
28
28
  let(:repo) { build(:repo, first_commit_sha: 'abc', last_commit_sha: 'def') }
29
29
 
30
30
  it 'should affect authors command' do
31
- repo.should_receive(:run).with('git shortlog -se abc..def').and_return("")
31
+ repo.should_receive(:run).with('git shortlog -se abc..def .').and_return("")
32
32
  repo.authors
33
33
  end
34
34
 
35
35
  it 'should affect commits command' do
36
- repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' abc..def | grep -v commit").and_return("")
36
+ repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' abc..def . | grep -v commit").and_return("")
37
37
  repo.commits
38
38
  end
39
39
 
@@ -7,7 +7,7 @@ describe GitStats::GitData::Commit do
7
7
  describe 'git output parsing' do
8
8
  context 'parsing git ls-tree output' do
9
9
  before {
10
- commit.repo.should_receive(:run).with('git ls-tree -r abc').and_return("100644 blob 5ade7ad51a75ee7db4eb06cecd3918d38134087d lib/git_stats/git_data/commit.rb
10
+ commit.repo.should_receive(:run).with('git ls-tree -r abc -- .').and_return("100644 blob 5ade7ad51a75ee7db4eb06cecd3918d38134087d lib/git_stats/git_data/commit.rb
11
11
  100644 blob db01e94677a8f72289848e507a52a43de2ea109a lib/git_stats/git_data/repo.rb
12
12
  100644 blob 1463eacb3ac9f95f21f360f1eb935a84a9ee0895 templates/index.haml
13
13
  100644 blob 31d8b960a67f195bdedaaf9e7aa70b2389f3f1a8 templates/assets/bootstrap/css/bootstrap.min.css
@@ -4,9 +4,9 @@ require 'spec_helper'
4
4
  describe GitStats::Generator do
5
5
  let(:repo_path) { 'repo_path' }
6
6
  let(:out_path) { 'out_path' }
7
- let(:generator) { GitStats::Generator.new(repo_path, out_path) }
7
+ let(:generator) { GitStats::Generator.new(path: repo_path, out_path: out_path) }
8
8
 
9
- before { Dir.stub!(:exists? => true) }
9
+ before { Dir.stub(:exists? => true) }
10
10
 
11
11
  it 'should raise exception if given repo path is not a git repository' do
12
12
  Dir.should_receive(:exists?).with("#{repo_path}/.git").and_return(false)
@@ -15,10 +15,8 @@ describe GitStats::Generator do
15
15
 
16
16
  it 'should pass command observer to repo' do
17
17
  repo = double('repo')
18
- GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, first_commit_sha: nil, last_commit_sha: "HEAD").and_return(repo)
19
-
20
- generator = GitStats::Generator.new(repo_path, out_path)
21
-
18
+ GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, out_path: out_path).and_return(repo)
19
+
22
20
  observer = double('observer')
23
21
  repo.should_receive(:add_command_observer).with(observer)
24
22
 
@@ -27,7 +25,7 @@ describe GitStats::Generator do
27
25
 
28
26
  it 'should render all templates with view data for this repo' do
29
27
  repo = double('repo')
30
- GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, first_commit_sha: nil, last_commit_sha: "HEAD").and_return(repo)
28
+ GitStats::GitData::Repo.should_receive(:new).with(path: repo_path, out_path: out_path).and_return(repo)
31
29
 
32
30
  view_data = double('view_data')
33
31
  GitStats::StatsView::ViewData.should_receive(:new).with(repo).and_return(view_data)
@@ -7,7 +7,7 @@ describe GitStats::GitData::Repo do
7
7
  describe 'git output parsing' do
8
8
  context 'invoking authors command' do
9
9
  before do
10
- repo.should_receive(:run).with('git shortlog -se HEAD').and_return(" 156 John Doe <john.doe@gmail.com>
10
+ repo.should_receive(:run).with('git shortlog -se HEAD .').and_return(" 156 John Doe <john.doe@gmail.com>
11
11
  53 Joe Doe <joe.doe@gmail.com>
12
12
  ")
13
13
  end
@@ -19,7 +19,7 @@ describe GitStats::GitData::Repo do
19
19
  end
20
20
 
21
21
  it 'should parse git revlist output to date sorted commits array' do
22
- repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD | grep -v commit").and_return(
22
+ repo.should_receive(:run).with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD . | grep -v commit").and_return(
23
23
  "e4412c3|1348603824|2012-09-25 22:10:24 +0200|john.doe@gmail.com
24
24
  ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
25
25
  5eab339|1345835073|2012-08-24 21:04:33 +0200|john.doe@gmail.com
@@ -28,13 +28,13 @@ ce34874|1347482927|2012-09-12 22:48:47 +0200|joe.doe@gmail.com
28
28
  repo.commits.should == [
29
29
  GitStats::GitData::Commit.new(
30
30
  repo: repo, sha: "5eab339", stamp: "1345835073", date: DateTime.parse("2012-08-24 21:04:33 +0200"),
31
- author: repo.authors.by_email("john.doe@gmail.com")),
31
+ author: repo.authors.first! { |a| a.email == "john.doe@gmail.com" }),
32
32
  GitStats::GitData::Commit.new(
33
33
  repo: repo, sha: "ce34874", stamp: "1347482927", date: DateTime.parse("2012-09-12 22:48:47 +0200"),
34
- author: repo.authors.by_email("joe.doe@gmail.com")),
34
+ author: repo.authors.first! { |a| a.email == "joe.doe@gmail.com" }),
35
35
  GitStats::GitData::Commit.new(
36
36
  repo: repo, sha: "e4412c3", stamp: "1348603824", date: DateTime.parse("2012-09-25 22:10:24 +0200"),
37
- author: repo.authors.by_email("john.doe@gmail.com"))
37
+ author: repo.authors.first! { |a| a.email == "john.doe@gmail.com" })
38
38
  ]
39
39
  end
40
40
  end
@@ -14,7 +14,7 @@ describe GitStats::GitData::ShortStat do
14
14
  {content: '', expect: [0, 0, 0]},
15
15
  ].each do |test|
16
16
  it "#{test[:content]} parsing" do
17
- commit.repo.should_receive(:run).with("git show --shortstat --oneline abc").and_return("abc some commit\n#{test[:content]}")
17
+ commit.repo.should_receive(:run).with("git show --shortstat --oneline abc -- .").and_return("abc some commit\n#{test[:content]}")
18
18
 
19
19
 
20
20
  commit.short_stat.should be_a(GitStats::GitData::ShortStat)
@@ -0,0 +1,41 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe GitStats::GitData::Tree do
5
+ let(:repo) { build(:test_repo_tree, tree_path: '.') }
6
+ let(:repo_tree) { build(:test_repo_tree, tree_path: './subdir_with_1_commit') }
7
+ let(:tree) { build(:tree, repo: repo_tree, relative_path: './subdir_with_1_commit') }
8
+
9
+ describe 'tree git output parsing' do
10
+ it 'should return . by default' do
11
+ repo.tree.should == GitStats::GitData::Tree.new(repo: repo, relative_path: '.')
12
+ end
13
+
14
+ it 'should return relative_path given by parameter' do
15
+ repo_tree.tree.should == GitStats::GitData::Tree.new(repo: repo, relative_path: './subdir_with_1_commit')
16
+ repo_tree.tree.relative_path.should == './subdir_with_1_commit'
17
+ tree.relative_path.should == './subdir_with_1_commit'
18
+ end
19
+
20
+ context 'invoking authors command' do
21
+ before do
22
+ repo_tree.should_receive(:run).with('git shortlog -se HEAD ./subdir_with_1_commit').and_return(" 3 Israel Revert <israelrevert@gmail.com>
23
+ ")
24
+ end
25
+
26
+ it 'should parse git shortlog output to authors hash' do
27
+ repo_tree.authors.should == [ build(:author, repo: repo_tree, name: "Israel Revert", email:"israelrevert@gmail.com") ]
28
+ end
29
+
30
+ it 'should parse git revlist output to date sorted commits array' do
31
+ repo_tree.should_receive(:run).
32
+ with("git rev-list --pretty=format:'%h|%at|%ai|%aE' HEAD ./subdir_with_1_commit | grep -v commit").
33
+ and_return("10d1814|1395407506|2014-03-21 14:11:46 +0100|israelrevert@gmail.com")
34
+ repo_tree.commits.should ==
35
+ [ GitStats::GitData::Commit.new( repo: repo, sha: "10d1814", stamp: "1395407506",
36
+ date: DateTime.parse("2014-03-21 14:11:46 +0100"),
37
+ author: repo.authors.first! { |a| a.email == "israelrevert@gmail.com" })]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -4,8 +4,8 @@ require 'integration/shared'
4
4
  describe GitStats::GitData::Activity do
5
5
  include_context "shared"
6
6
 
7
- let(:tg) { repo.authors.by_email('tomasz.gieniusz@gmail.com') }
8
- let(:jd) { repo.authors.by_email('john.doe@gmail.com') }
7
+ let(:tg) { repo.authors.first! { |a| a.email == 'tomasz.gieniusz@gmail.com' } }
8
+ let(:jd) { repo.authors.first! { |a| a.email == 'john.doe@gmail.com' } }
9
9
 
10
10
  it 'should filter commits to author' do
11
11
  tg.commits.map(&:sha).should =~ %w(b3b4f81 d60b5ec ab47ef8 2c11f5e c87ecf9 b621a5d 4e7d0e9 872955c)
@@ -9,7 +9,7 @@ describe GitStats::GitData::Repo do
9
9
  end
10
10
 
11
11
  it 'should retrieve correct file content for old file' do
12
- repo.commits.by_sha('c87ecf9').files.by_filename('test.txt').content.should == "bb
12
+ repo.commits.first! { |c| c.sha == 'c87ecf9' }.files.first! { |f| f.filename == 'test.txt' }.content.should == "bb
13
13
 
14
14
 
15
15
 
@@ -18,7 +18,7 @@ test
18
18
  end
19
19
 
20
20
  it 'should retrieve correct file content for the newest file' do
21
- file = repo.files.by_filename('test.txt')
21
+ file = repo.files.first! { |f| f.filename == 'test.txt' }
22
22
  file.content.should == "bb
23
23
 
24
24
  testtest
@@ -44,3 +44,94 @@ shared_context "shared" do
44
44
  build(:author, repo: repo, name: "John Doe", email: "john.doe@gmail.com"),
45
45
  ] }
46
46
  end
47
+
48
+
49
+ shared_context "tree_subdir_with_1_commit" do
50
+ let(:repo) { build(:test_repo_tree, last_commit_sha: 'HEAD', tree_path: './subdir_with_1_commit') }
51
+ let(:commit_dates) { [
52
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
53
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
54
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
55
+ ] }
56
+ let(:commit_dates_with_empty) {[
57
+ Date.new(2014, 03, 21),
58
+ Date.new(2014, 03, 21),
59
+ Date.new(2014, 03, 21),
60
+ ]}
61
+ let(:tg_commit_dates) { [
62
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
63
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
64
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
65
+ ] }
66
+ let(:jd_commit_dates) { [
67
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
68
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
69
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
70
+ ] }
71
+
72
+ let(:expected_authors) { [
73
+ build(:author, repo: repo, name: "Israel Revert", email: "israelrevert@gmail.com"),
74
+ ] }
75
+ end
76
+
77
+ shared_context "tree_subdir_with_2_commit" do
78
+ let(:repo) { build(:test_repo_tree, last_commit_sha: 'HEAD', tree_path: './subdir_with_2_commits') }
79
+ let(:commit_dates) { [
80
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
81
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
82
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
83
+ ] }
84
+ let(:commit_dates_with_empty) {[
85
+ Date.new(2014, 03, 21),
86
+ Date.new(2014, 03, 21),
87
+ Date.new(2014, 03, 21),
88
+ ]}
89
+ let(:tg_commit_dates) { [
90
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
91
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
92
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
93
+ ] }
94
+ let(:jd_commit_dates) { [
95
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
96
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
97
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
98
+ ] }
99
+
100
+ let(:expected_authors) { [
101
+ build(:author, repo: repo, name: "Israel Revert", email: "israelrevert@gmail.com"),
102
+ ] }
103
+ end
104
+
105
+
106
+
107
+ # 5fd0f5e|1395407567|2014-03-21 14:12:47 +0100|israelrevert@gmail.com
108
+ # 435e0ef|1395407543|2014-03-21 14:12:23 +0100|israelrevert@gmail.com
109
+ # 10d1814|1395407506|2014-03-21 14:11:46 +0100|israelrevert@gmail.com
110
+
111
+ shared_context "tree" do
112
+ let(:repo) { build(:test_repo_tree, last_commit_sha: 'HEAD') }
113
+ let(:commit_dates) { [
114
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
115
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
116
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
117
+ ] }
118
+ let(:commit_dates_with_empty) {[
119
+ Date.new(2014, 03, 21),
120
+ Date.new(2014, 03, 21),
121
+ Date.new(2014, 03, 21),
122
+ ]}
123
+ let(:tg_commit_dates) { [
124
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
125
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
126
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
127
+ ] }
128
+ let(:jd_commit_dates) { [
129
+ DateTime.parse('2014-03-21 14:11:46 +0100'),
130
+ DateTime.parse('2014-03-21 14:12:23 +0100'),
131
+ DateTime.parse('2014-03-21 14:12:47 +0100'),
132
+ ] }
133
+
134
+ let(:expected_authors) { [
135
+ build(:author, repo: repo, name: "Israel Revert", email: "israelrevert@gmail.com"),
136
+ ] }
137
+ end
@@ -0,0 +1,197 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'integration/shared'
3
+
4
+ describe GitStats::GitData::Tree do
5
+ include_context "tree"
6
+
7
+ it 'should gather all authors' do
8
+ repo.authors.should =~ expected_authors
9
+ end
10
+
11
+ it 'should calculate correct commits period' do
12
+ repo.commits_period.should == [DateTime.parse('2014-03-21 14:11:46 +0100'),
13
+ DateTime.parse('2014-03-21 14:12:47 +0100')]
14
+ end
15
+
16
+ it 'should gather all commits sorted by date' do
17
+ repo.commits.map(&:sha).should =~ %w(10d1814 435e0ef 5fd0f5e)
18
+ end
19
+
20
+ it 'should return project name from dir' do
21
+ repo.project_name.should == 'test_repo_tree'
22
+ end
23
+
24
+ it 'should return project version as last commit hash' do
25
+ repo.project_version.should == '5fd0f5e'
26
+ end
27
+
28
+ it 'should count files in repo' do
29
+ repo.files_count.should == 4
30
+ end
31
+
32
+ it 'should count files by date' do
33
+ repo.files_count_by_date.keys == Hash[commit_dates_with_empty.zip [2, 3, 4]]
34
+ end
35
+
36
+ it 'should count lines by date' do
37
+ repo.files_count_by_date.values == Hash[commit_dates_with_empty.zip [1, 2, 2]]
38
+ end
39
+
40
+ it 'should count all lines in repo' do
41
+ repo.lines_count.should == 0
42
+ end
43
+
44
+ it 'should count files by extension in repo' do
45
+ repo.files_by_extension_count.should == {'' => 4}
46
+ end
47
+
48
+ it 'should count lines by extension in repo' do
49
+ repo.lines_by_extension.should == {}
50
+ end
51
+
52
+ it 'should count commits_count_by_author' do
53
+ repo.commits_count_by_author.keys.should == expected_authors
54
+ repo.commits_count_by_author.values.should == [3]
55
+ end
56
+
57
+ it 'should count lines_added_by_author' do
58
+ repo.insertions_by_author.keys.should == expected_authors
59
+ repo.insertions_by_author.values.should == [0]
60
+ end
61
+
62
+ it 'should count lines_deleted_by_author' do
63
+ repo.deletions_by_author.keys.should == expected_authors
64
+ repo.deletions_by_author.values.should == [0]
65
+ end
66
+
67
+ end
68
+
69
+ describe GitStats::GitData::Tree do
70
+ include_context "tree_subdir_with_1_commit"
71
+
72
+ it 'should gather all authors' do
73
+ repo.authors.should =~ expected_authors
74
+ end
75
+
76
+ it 'should calculate correct commits period' do
77
+ repo.commits_period.should == [DateTime.parse('2014-03-21 14:11:46 +0100'),
78
+ DateTime.parse('2014-03-21 14:11:46 +0100')]
79
+ end
80
+
81
+ it 'should gather all commits sorted by date' do
82
+ repo.commits.map(&:sha).should =~ %w(10d1814)
83
+ end
84
+
85
+ it 'should return project name from dir' do
86
+ repo.project_name.should == 'test_repo_tree/subdir_with_1_commit'
87
+ end
88
+
89
+ it 'should return project version as last commit hash' do
90
+ repo.project_version.should == '5fd0f5e'
91
+ end
92
+
93
+ it 'should count files in repo' do
94
+ repo.files_count.should == 2
95
+ end
96
+
97
+ it 'should count files by date' do
98
+ repo.files_count_by_date.keys == Hash[commit_dates_with_empty.zip [2]]
99
+ end
100
+
101
+ it 'should count lines by date' do
102
+ repo.files_count_by_date.values == Hash[commit_dates_with_empty.zip [1]]
103
+ end
104
+
105
+ it 'should count all lines in repo' do
106
+ repo.lines_count.should == 0
107
+ end
108
+
109
+ it 'should count files by extension in repo' do
110
+ repo.files_by_extension_count.should == {'' => 2}
111
+ end
112
+
113
+ it 'should count lines by extension in repo' do
114
+ repo.lines_by_extension.should == {}
115
+ end
116
+
117
+ it 'should count commits_count_by_author' do
118
+ repo.commits_count_by_author.keys.should == expected_authors
119
+ repo.commits_count_by_author.values.should == [1]
120
+ end
121
+
122
+ it 'should count lines_added_by_author' do
123
+ repo.insertions_by_author.keys.should == expected_authors
124
+ repo.insertions_by_author.values.should == [0]
125
+ end
126
+
127
+ it 'should count lines_deleted_by_author' do
128
+ repo.deletions_by_author.keys.should == expected_authors
129
+ repo.deletions_by_author.values.should == [0]
130
+ end
131
+
132
+ end
133
+
134
+ describe GitStats::GitData::Tree do
135
+ include_context "tree_subdir_with_2_commit"
136
+
137
+ it 'should gather all authors' do
138
+ repo.authors.should =~ expected_authors
139
+ end
140
+
141
+ it 'should calculate correct commits period' do
142
+ repo.commits_period.should == [DateTime.parse('2014-03-21 14:12:23 +0100'),
143
+ DateTime.parse('2014-03-21 14:12:47 +0100')]
144
+ end
145
+
146
+ it 'should gather all commits sorted by date' do
147
+ repo.commits.map(&:sha).should =~ %w(435e0ef 5fd0f5e)
148
+ end
149
+
150
+ it 'should return project name from dir' do
151
+ repo.project_name.should == 'test_repo_tree/subdir_with_2_commits'
152
+ end
153
+
154
+ it 'should return project version as last commit hash' do
155
+ repo.project_version.should == '5fd0f5e'
156
+ end
157
+
158
+ it 'should count files in repo' do
159
+ repo.files_count.should == 2
160
+ end
161
+
162
+ it 'should count files by date' do
163
+ repo.files_count_by_date.keys == Hash[commit_dates_with_empty.zip [1, 2]]
164
+ end
165
+
166
+ it 'should count lines by date' do
167
+ repo.files_count_by_date.values == Hash[commit_dates_with_empty.zip [2, 2]]
168
+ end
169
+
170
+ it 'should count all lines in repo' do
171
+ repo.lines_count.should == 0
172
+ end
173
+
174
+ it 'should count files by extension in repo' do
175
+ repo.files_by_extension_count.should == {'' => 2}
176
+ end
177
+
178
+ it 'should count lines by extension in repo' do
179
+ repo.lines_by_extension.should == {}
180
+ end
181
+
182
+ it 'should count commits_count_by_author' do
183
+ repo.commits_count_by_author.keys.should == expected_authors
184
+ repo.commits_count_by_author.values.should == [2]
185
+ end
186
+
187
+ it 'should count lines_added_by_author' do
188
+ repo.insertions_by_author.keys.should == expected_authors
189
+ repo.insertions_by_author.values.should == [0]
190
+ end
191
+
192
+ it 'should count lines_deleted_by_author' do
193
+ repo.deletions_by_author.keys.should == expected_authors
194
+ repo.deletions_by_author.values.should == [0]
195
+ end
196
+
197
+ end