git_statistics 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +1 -0
- data/lib/git_statistics/collector.rb +2 -2
- data/lib/git_statistics/version.rb +1 -1
- data/spec/collector_spec.rb +82 -29
- data/spec/commits_spec.rb +73 -0
- data/spec/utilities_spec.rb +2 -5
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
* [0.4.1 - October 9, 2012](https://github.com/kevinjalbert/git_statistics/compare/v0.4.0...v0.4.1)
|
3
4
|
* [0.4.0 - September 25, 2012](https://github.com/kevinjalbert/git_statistics/compare/v0.3.0...v0.4.0)
|
4
5
|
* [0.3.0 - September 12, 2012](https://github.com/kevinjalbert/git_statistics/compare/v0.2.0...v0.3.0)
|
5
6
|
* [0.2.0 - September 6, 2012](https://github.com/kevinjalbert/git_statistics/compare/v0.1.2...v0.2.0)
|
@@ -40,8 +40,8 @@ module GitStatistics
|
|
40
40
|
# Extract the buffer (commit) when we match ','x5 in the log format (delimeter)
|
41
41
|
if line.split(',').size == 5
|
42
42
|
|
43
|
-
# Sometimes 'git log' doesn't populate the buffer, try fallback option if so
|
44
|
-
buffer = fall_back_collect_commit(
|
43
|
+
# Sometimes 'git log' doesn't populate the buffer (i.e., merges), try fallback option if so
|
44
|
+
buffer = fall_back_collect_commit(buffer[0].split(',').first) if buffer.size == 1
|
45
45
|
|
46
46
|
extract_commit(buffer) if not buffer.empty?
|
47
47
|
buffer = []
|
data/spec/collector_spec.rb
CHANGED
@@ -8,6 +8,83 @@ describe Collector do
|
|
8
8
|
let(:pretty) {false}
|
9
9
|
let(:collector) {Collector.new(verbose, limit, fresh, pretty)}
|
10
10
|
|
11
|
+
# Create buffer which is an array of cleaned lines
|
12
|
+
let(:buffer) {
|
13
|
+
buffer = []
|
14
|
+
fixture(fixture_file).readlines.each do |line|
|
15
|
+
buffer << Utilities.clean_string(line)
|
16
|
+
end
|
17
|
+
buffer
|
18
|
+
}
|
19
|
+
|
20
|
+
describe "#collect" do
|
21
|
+
let(:branch) {""}
|
22
|
+
let(:email) {false}
|
23
|
+
let(:merge) {true}
|
24
|
+
let(:time_since) {"--since \"Tue Sep 25 14:15:44 2012 -0400\""}
|
25
|
+
let(:time_until) {"--until \"Tue Sep 25 14:45:05 2012 -0400\""}
|
26
|
+
let(:author) {"Kevin Jalbert"}
|
27
|
+
|
28
|
+
let(:setup) {
|
29
|
+
collector.collect(branch, time_since, time_until)
|
30
|
+
collector.commits.calculate_statistics(email, merge)
|
31
|
+
@subject = collector.commits.stats[author]
|
32
|
+
}
|
33
|
+
|
34
|
+
context "with no merge commits" do
|
35
|
+
let(:merge) {false}
|
36
|
+
let(:time_since) {"--since \"Tue Sep 10 14:15:44 2012 -0400\""}
|
37
|
+
let(:time_until) {"--until \"Tue Sep 11 14:45:05 2012 -0400\""}
|
38
|
+
|
39
|
+
before(:all) {setup}
|
40
|
+
|
41
|
+
it{@subject[:additions].should == 276}
|
42
|
+
it{@subject[:deletions].should == 99}
|
43
|
+
it{@subject[:commits].should == 4}
|
44
|
+
it{@subject[:merges].should == 0}
|
45
|
+
|
46
|
+
it{@subject[:languages][:Ruby][:additions].should == 270}
|
47
|
+
it{@subject[:languages][:Ruby][:deletions].should == 99}
|
48
|
+
it{@subject[:languages][:Ruby][:create].should == 2}
|
49
|
+
it{@subject[:languages][:Unknown][:additions].should == 6}
|
50
|
+
it{@subject[:languages][:Unknown][:deletions].should == 0}
|
51
|
+
it{@subject[:languages][:Unknown][:create].should == 1}
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with merge commits and merge option" do
|
55
|
+
before(:all) {setup}
|
56
|
+
|
57
|
+
it{@subject[:additions].should == 667}
|
58
|
+
it{@subject[:deletions].should == 483}
|
59
|
+
it{@subject[:commits].should == 3}
|
60
|
+
it{@subject[:merges].should == 1}
|
61
|
+
|
62
|
+
it{@subject[:languages][:Markdown][:additions].should == 1}
|
63
|
+
it{@subject[:languages][:Markdown][:deletions].should == 0}
|
64
|
+
it{@subject[:languages][:Ruby][:additions].should == 654}
|
65
|
+
it{@subject[:languages][:Ruby][:deletions].should == 483}
|
66
|
+
it{@subject[:languages][:Unknown][:additions].should == 12}
|
67
|
+
it{@subject[:languages][:Unknown][:deletions].should == 0}
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with merge commits and no merge option" do
|
71
|
+
let(:merge) {false}
|
72
|
+
before(:all) {setup}
|
73
|
+
|
74
|
+
it{@subject[:additions].should == 8}
|
75
|
+
it{@subject[:deletions].should == 1}
|
76
|
+
it{@subject[:commits].should == 2}
|
77
|
+
it{@subject[:merges].should == 0}
|
78
|
+
|
79
|
+
it{@subject[:languages][:Markdown][:additions].should == 1}
|
80
|
+
it{@subject[:languages][:Markdown][:deletions].should == 0}
|
81
|
+
it{@subject[:languages][:Ruby][:additions].should == 1}
|
82
|
+
it{@subject[:languages][:Ruby][:deletions].should == 1}
|
83
|
+
it{@subject[:languages][:Unknown][:additions].should == 6}
|
84
|
+
it{@subject[:languages][:Unknown][:deletions].should == 0}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
11
88
|
describe "#collect_branches" do
|
12
89
|
let(:branches) {collector.collect_branches(fixture(fixture_file))}
|
13
90
|
|
@@ -122,6 +199,7 @@ describe Collector do
|
|
122
199
|
|
123
200
|
describe "#identify_changed_files" do
|
124
201
|
let(:files) {collector.identify_changed_files(buffer)}
|
202
|
+
let(:fixture_file) {"commit_buffer_changes.txt"}
|
125
203
|
|
126
204
|
context "with no changes" do
|
127
205
|
let(:buffer) {[]}
|
@@ -130,15 +208,6 @@ describe Collector do
|
|
130
208
|
end
|
131
209
|
|
132
210
|
context "with all types (create,delete,rename,copy) of files" do
|
133
|
-
# Create buffer which is an array of cleaned lines
|
134
|
-
let(:buffer) {
|
135
|
-
buffer = []
|
136
|
-
fixture("commit_buffer_changes.txt").readlines.each do |line|
|
137
|
-
buffer << Utilities.clean_string(line)
|
138
|
-
end
|
139
|
-
buffer
|
140
|
-
}
|
141
|
-
|
142
211
|
it {files.size.should == 5}
|
143
212
|
|
144
213
|
it {files[0][:additions].should == 45}
|
@@ -170,14 +239,6 @@ describe Collector do
|
|
170
239
|
end
|
171
240
|
|
172
241
|
describe "#extract_commit" do
|
173
|
-
# Create buffer which is an array of cleaned lines
|
174
|
-
let(:buffer) {
|
175
|
-
buffer = []
|
176
|
-
fixture(fixture_file).readlines.each do |line|
|
177
|
-
buffer << Utilities.clean_string(line)
|
178
|
-
end
|
179
|
-
buffer
|
180
|
-
}
|
181
242
|
let(:data) {collector.extract_commit(buffer)}
|
182
243
|
|
183
244
|
context "with valid buffer" do
|
@@ -235,24 +296,16 @@ describe Collector do
|
|
235
296
|
end
|
236
297
|
|
237
298
|
describe "#fall_back_collect_commit" do
|
238
|
-
let(:
|
299
|
+
let(:results) {collector.fall_back_collect_commit(sha)}
|
239
300
|
context "with valid sha" do
|
240
|
-
|
241
|
-
let(:expected) {
|
242
|
-
expected = []
|
243
|
-
fixture("commit_buffer_whole.txt").readlines.each do |line|
|
244
|
-
expected << Utilities.clean_string(line)
|
245
|
-
end
|
246
|
-
expected
|
247
|
-
}
|
301
|
+
let(:fixture_file) {"commit_buffer_whole.txt"}
|
248
302
|
let(:sha) {"260bc61e2c42930d91f3503c5849b0a2351275cf"}
|
249
|
-
|
250
|
-
it {buffer.should == expected}
|
303
|
+
it {results.should == buffer}
|
251
304
|
end
|
252
305
|
|
253
306
|
context "with invalid sha" do
|
254
307
|
let(:sha) {"111111aa111a11111a11aa11aaaa11a111111a11"}
|
255
|
-
it {
|
308
|
+
it {results.should == nil}
|
256
309
|
end
|
257
310
|
end
|
258
311
|
|
data/spec/commits_spec.rb
CHANGED
@@ -61,6 +61,79 @@ describe Commits do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
describe "#process_commits" do
|
65
|
+
let(:commits) {collector.commits.load(fixture(fixture_file))}
|
66
|
+
let(:type) {:author}
|
67
|
+
|
68
|
+
context "with merge" do
|
69
|
+
let(:merge) {true}
|
70
|
+
subject {
|
71
|
+
commits.process_commits(type, merge)
|
72
|
+
commits.stats[author_name]
|
73
|
+
}
|
74
|
+
|
75
|
+
context "on first author" do
|
76
|
+
let(:author_name) {"Kevin Jalbert"}
|
77
|
+
it {subject[:additions].should == 153}
|
78
|
+
it {subject[:deletions].should == 5}
|
79
|
+
it {subject[:commits].should == 2}
|
80
|
+
it {subject[:create].should == 3}
|
81
|
+
it {subject[:merges].should == 1}
|
82
|
+
|
83
|
+
it {subject[:languages][:Markdown][:additions].should == 18}
|
84
|
+
it {subject[:languages][:Markdown][:deletions].should == 1}
|
85
|
+
it {subject[:languages][:Markdown][:create].should == 1}
|
86
|
+
it {subject[:languages][:Ruby][:additions].should == 135}
|
87
|
+
it {subject[:languages][:Ruby][:deletions].should == 4}
|
88
|
+
it {subject[:languages][:Ruby][:create].should == 2}
|
89
|
+
end
|
90
|
+
|
91
|
+
context "on second author" do
|
92
|
+
let(:author_name) {"John Smith"}
|
93
|
+
it {subject[:additions].should == 64}
|
94
|
+
it {subject[:deletions].should == 16}
|
95
|
+
it {subject[:commits].should == 1}
|
96
|
+
|
97
|
+
it {subject[:languages][:Ruby][:additions].should == 64}
|
98
|
+
it {subject[:languages][:Ruby][:deletions].should == 16}
|
99
|
+
it {subject[:languages][:Ruby][:create].should == 0}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "without merge" do
|
104
|
+
let(:merge) {false}
|
105
|
+
subject {
|
106
|
+
commits.process_commits(type, merge)
|
107
|
+
commits.stats[author_name]
|
108
|
+
}
|
109
|
+
|
110
|
+
context "on first author" do
|
111
|
+
let(:author_name) {"Kevin Jalbert"}
|
112
|
+
it {subject[:additions].should == 73}
|
113
|
+
it {subject[:deletions].should == 0}
|
114
|
+
it {subject[:commits].should == 1}
|
115
|
+
it {subject[:create].should == 2}
|
116
|
+
|
117
|
+
it {subject[:languages][:Markdown][:additions].should == 11}
|
118
|
+
it {subject[:languages][:Markdown][:deletions].should == 0}
|
119
|
+
it {subject[:languages][:Markdown][:create].should == 1}
|
120
|
+
it {subject[:languages][:Ruby][:additions].should == 62}
|
121
|
+
it {subject[:languages][:Ruby][:deletions].should == 0}
|
122
|
+
it {subject[:languages][:Ruby][:create].should == 1}
|
123
|
+
end
|
124
|
+
|
125
|
+
context "on second author" do
|
126
|
+
let(:author_name) {"John Smith"}
|
127
|
+
it {subject[:additions].should == 64}
|
128
|
+
it {subject[:deletions].should == 16}
|
129
|
+
it {subject[:commits].should == 1}
|
130
|
+
|
131
|
+
it {subject[:languages][:Ruby][:additions].should == 64}
|
132
|
+
it {subject[:languages][:Ruby][:deletions].should == 16}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
64
137
|
describe "#author_top_n_type" do
|
65
138
|
let(:sort) {:deletions}
|
66
139
|
|
data/spec/utilities_spec.rb
CHANGED
@@ -24,10 +24,10 @@ describe Utilities do
|
|
24
24
|
|
25
25
|
describe "#find_longest_length" do
|
26
26
|
let(:max) {nil}
|
27
|
+
let(:list) {[]}
|
27
28
|
let(:results) {Utilities.find_longest_length(list, max)}
|
28
29
|
|
29
30
|
context "with empty list" do
|
30
|
-
let(:list) {[]}
|
31
31
|
it {results.should == nil}
|
32
32
|
end
|
33
33
|
|
@@ -37,7 +37,6 @@ describe Utilities do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
context "with preset minimum length" do
|
40
|
-
let(:list) {[]}
|
41
40
|
let(:max) {10}
|
42
41
|
it {results.should == 10}
|
43
42
|
end
|
@@ -202,9 +201,7 @@ describe Utilities do
|
|
202
201
|
end
|
203
202
|
|
204
203
|
context "with no files" do
|
205
|
-
it
|
206
|
-
files.should == 0
|
207
|
-
end
|
204
|
+
it {files.should == 0}
|
208
205
|
end
|
209
206
|
end
|
210
207
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-09
|
12
|
+
date: 2012-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|