git_fame 2.5.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/exe/git-fame +9 -0
- data/lib/git_fame/author.rb +5 -75
- data/lib/git_fame/base.rb +10 -521
- data/lib/git_fame/collector.rb +45 -0
- data/lib/git_fame/command.rb +159 -0
- data/lib/git_fame/contribution.rb +12 -0
- data/lib/git_fame/diff.rb +25 -0
- data/lib/git_fame/error.rb +5 -0
- data/lib/git_fame/extension.rb +16 -0
- data/lib/git_fame/filter.rb +43 -0
- data/lib/git_fame/render/extension.rb +26 -0
- data/lib/git_fame/render.rb +38 -0
- data/lib/git_fame/result.rb +29 -4
- data/lib/git_fame/types.rb +11 -0
- data/lib/git_fame/version.rb +3 -1
- data/lib/git_fame.rb +16 -3
- metadata +79 -98
- data/.gitignore +0 -20
- data/.gitmodules +0 -3
- data/.rspec +0 -7
- data/.travis.yml +0 -21
- data/Gemfile +0 -4
- data/LICENSE +0 -22
- data/README.md +0 -137
- data/Rakefile +0 -15
- data/bin/git-fame +0 -58
- data/git_fame.gemspec +0 -43
- data/lib/git_fame/blame_parser.rb +0 -83
- data/lib/git_fame/commit_range.rb +0 -27
- data/lib/git_fame/errors.rb +0 -6
- data/lib/git_fame/file.rb +0 -13
- data/lib/git_fame/helper.rb +0 -11
- data/lib/git_fame/silent_progressbar.rb +0 -20
- data/spec/bin_spec.rb +0 -116
- data/spec/git_fame_spec.rb +0 -464
- data/spec/spec_helper.rb +0 -64
- data/spec/support/startup.rb +0 -21
data/spec/git_fame_spec.rb
DELETED
@@ -1,464 +0,0 @@
|
|
1
|
-
describe GitFame::Base do
|
2
|
-
let(:subject) { GitFame::Base.new({ repository: repository }) }
|
3
|
-
|
4
|
-
describe "#authors" do
|
5
|
-
it "should have a list of authors" do
|
6
|
-
subject.should have(3).authors
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "author" do
|
10
|
-
let(:author) do
|
11
|
-
subject.authors.find do |author|
|
12
|
-
author.name.include?("Magnus Holm")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should have a bunch of commits" do
|
17
|
-
author.raw(:commits).should eq(41)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should respond to name" do
|
21
|
-
author.name.should eq("Magnus Holm")
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should have a number of locs" do
|
25
|
-
author.raw(:loc).should eq(575)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should have a number of files" do
|
29
|
-
author.raw(:files).should eq(4)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should have a distribution" do
|
33
|
-
author.distribution.should eq("53.7 / 58.6 / 25.0")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "format" do
|
38
|
-
let(:author) do
|
39
|
-
GitFame::Author.new({
|
40
|
-
raw_commits: 12345,
|
41
|
-
raw_files: 6789,
|
42
|
-
raw_loc: 1234
|
43
|
-
})
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should format #commits" do
|
47
|
-
author.commits.should eq("12,345")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should format #files" do
|
51
|
-
author.files.should eq("6,789")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should format #loc" do
|
55
|
-
author.loc.should eq("1,234")
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "total" do
|
61
|
-
it "should respond to #loc, #commits and #files" do
|
62
|
-
subject.files.should eq(16)
|
63
|
-
subject.commits.should eq(70)
|
64
|
-
subject.loc.should eq(1071)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "sort" do
|
69
|
-
it "should be able to sort #authors by name" do
|
70
|
-
authors = GitFame::Base.new({
|
71
|
-
repository: repository,
|
72
|
-
sort: "name"
|
73
|
-
}).authors
|
74
|
-
authors.map(&:name).
|
75
|
-
should eq(["7rans", "Linus Oleander", "Magnus Holm"])
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should be able to sort #authors by commits" do
|
79
|
-
authors = GitFame::Base.new({
|
80
|
-
repository: repository,
|
81
|
-
sort: "commits"
|
82
|
-
}).authors
|
83
|
-
|
84
|
-
authors.map(&:name).
|
85
|
-
should eq(["Magnus Holm", "Linus Oleander", "7rans"])
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should be able to sort #authors by files" do
|
89
|
-
authors = GitFame::Base.new({
|
90
|
-
repository: repository,
|
91
|
-
sort: "files"
|
92
|
-
}).authors
|
93
|
-
authors.map(&:name).
|
94
|
-
should eq(["7rans", "Linus Oleander", "Magnus Holm"])
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should be able to sort #authors by loc" do
|
98
|
-
authors = GitFame::Base.new({
|
99
|
-
repository: repository,
|
100
|
-
sort: "loc"
|
101
|
-
}).authors
|
102
|
-
authors.map(&:name).
|
103
|
-
should eq(["Magnus Holm", "7rans", "Linus Oleander"])
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
describe "exclude" do
|
108
|
-
let(:subject) do
|
109
|
-
GitFame::Base.new({
|
110
|
-
repository: repository,
|
111
|
-
exclude: "lib/*"
|
112
|
-
})
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should exclude the lib folder" do
|
116
|
-
subject.file_list.map(&:path).should_not include("lib/gash.rb")
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should exclude non rb or rdoc files" do
|
120
|
-
subject.file_list.map(&:path).should include("HISTORY")
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should exclude non matching paths" do
|
124
|
-
subject.file_list.map(&:path).should include("spec/gash_spec.rb")
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe "types" do
|
129
|
-
let(:subject) do
|
130
|
-
GitFame::Base.new({
|
131
|
-
repository: repository,
|
132
|
-
by_type: true,
|
133
|
-
extensions: "rb,rdoc"
|
134
|
-
})
|
135
|
-
end
|
136
|
-
|
137
|
-
let(:author) do
|
138
|
-
subject.authors.find do |author|
|
139
|
-
author.name == "7rans"
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should break out counts by file type" do
|
144
|
-
author.file_type_counts["rdoc"].should eq(1)
|
145
|
-
end
|
146
|
-
|
147
|
-
it "should output zero for file types the author hasn't touched" do
|
148
|
-
author.file_type_counts["derp"].should eq(0)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "include" do
|
153
|
-
let(:subject) do
|
154
|
-
GitFame::Base.new({
|
155
|
-
repository: repository,
|
156
|
-
include: "lib/*,spec/*"
|
157
|
-
})
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should exclude the lib folder" do
|
161
|
-
subject.file_list.map(&:path).should include("lib/gash.rb")
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should exclude non rb or rdoc files" do
|
165
|
-
subject.file_list.map(&:path).should_not include("HISTORY")
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should exclude non matching paths" do
|
169
|
-
subject.file_list.map(&:path).should include("spec/gash_spec.rb")
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "glob" do
|
174
|
-
it "should exclude" do
|
175
|
-
GitFame::Base.new({
|
176
|
-
repository: repository,
|
177
|
-
exclude: "lib/*.rb"
|
178
|
-
}).file_list.map(&:path).should_not include("lib/gash.rb")
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should include" do
|
182
|
-
GitFame::Base.new({
|
183
|
-
repository: repository,
|
184
|
-
include: "lib/*.rb"
|
185
|
-
}).file_list.map(&:path).should include("lib/gash.rb")
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "#pretty_print" do
|
190
|
-
it "should print" do
|
191
|
-
lambda {
|
192
|
-
2.times { subject.pretty_puts }
|
193
|
-
}.should_not raise_error
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe "#csv_print" do
|
198
|
-
it "should print" do
|
199
|
-
lambda {
|
200
|
-
subject.csv_puts
|
201
|
-
}.should_not raise_error
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should be equal to" do
|
205
|
-
subject.to_csv.should eq([
|
206
|
-
"name,loc,commits,files,distribution\n",
|
207
|
-
"Magnus Holm,575,41,4,53.7 / 58.6 / 25.0\n",
|
208
|
-
"7rans,360,6,10,33.6 / 8.6 / 62.5\n",
|
209
|
-
"Linus Oleander,136,23,7,12.7 / 32.9 / 43.8\n",
|
210
|
-
].join)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
describe "branches", :this do
|
215
|
-
it "should handle existing branches" do
|
216
|
-
GitFame::Base.new({
|
217
|
-
repository: repository,
|
218
|
-
branch: "master"
|
219
|
-
}).authors
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should raise an error if branch doesn't exist" do
|
223
|
-
expect {
|
224
|
-
GitFame::Base.new({
|
225
|
-
repository: repository,
|
226
|
-
branch: "-----"
|
227
|
-
}).authors
|
228
|
-
}.to raise_error(GitFame::Error)
|
229
|
-
end
|
230
|
-
|
231
|
-
it "should not raise on empty branch (use fallback)" do
|
232
|
-
GitFame::Base.new({
|
233
|
-
repository: repository,
|
234
|
-
branch: ""
|
235
|
-
}).authors.should_not be_empty
|
236
|
-
|
237
|
-
GitFame::Base.new({
|
238
|
-
repository: repository,
|
239
|
-
branch: nil
|
240
|
-
}).authors.should_not be_empty
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe "after", :this do
|
245
|
-
it "should raise error if 'after' is to far in the future" do
|
246
|
-
lambda do
|
247
|
-
GitFame::Base.new({
|
248
|
-
repository: repository,
|
249
|
-
after: "2020-01-01"
|
250
|
-
}).commits
|
251
|
-
end.should raise_error(GitFame::Error)
|
252
|
-
end
|
253
|
-
|
254
|
-
it "should handle same day as HEAD" do
|
255
|
-
GitFame::Base.new({
|
256
|
-
repository: repository,
|
257
|
-
after: "2012-05-23"
|
258
|
-
}).commits.should eq(1)
|
259
|
-
end
|
260
|
-
|
261
|
-
it "should handle an out of scope 'after' date" do
|
262
|
-
GitFame::Base.new({
|
263
|
-
repository: repository,
|
264
|
-
after: "2000-01-01"
|
265
|
-
}).commits.should eq(70)
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
describe "before", :this do
|
270
|
-
it "should raise error if 'before' is to far back in history" do
|
271
|
-
lambda do
|
272
|
-
GitFame::Base.new({
|
273
|
-
repository: repository,
|
274
|
-
before: "1972-01-01"
|
275
|
-
}).commits
|
276
|
-
end.should raise_error(GitFame::Error)
|
277
|
-
end
|
278
|
-
|
279
|
-
it "should handle same day as last commit" do
|
280
|
-
GitFame::Base.new({
|
281
|
-
repository: repository,
|
282
|
-
before: "2008-08-31"
|
283
|
-
}).commits.should eq(1)
|
284
|
-
end
|
285
|
-
|
286
|
-
it "should handle an out of scope 'before' date" do
|
287
|
-
GitFame::Base.new({
|
288
|
-
repository: repository,
|
289
|
-
before: "2050-01-01"
|
290
|
-
}).commits.should eq(70)
|
291
|
-
end
|
292
|
-
|
293
|
-
it "should handle same day as last commit" do
|
294
|
-
GitFame::Base.new({
|
295
|
-
repository: repository,
|
296
|
-
before: "2008-08-31"
|
297
|
-
}).commits.should eq(1)
|
298
|
-
end
|
299
|
-
|
300
|
-
it "should validate before date" do
|
301
|
-
lambda do
|
302
|
-
GitFame::Base.new({
|
303
|
-
repository: repository,
|
304
|
-
before: "----"
|
305
|
-
})
|
306
|
-
end.should raise_error(GitFame::Error)
|
307
|
-
end
|
308
|
-
|
309
|
-
it "should validate before date" do
|
310
|
-
lambda do
|
311
|
-
GitFame::Base.new({
|
312
|
-
repository: repository,
|
313
|
-
after: "----"
|
314
|
-
})
|
315
|
-
end.should raise_error(GitFame::Error)
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "span", :this do
|
320
|
-
it "should handle spans as inclusive" do
|
321
|
-
GitFame::Base.new({
|
322
|
-
repository: repository,
|
323
|
-
after: "2008-09-01",
|
324
|
-
before: "2008-09-03"
|
325
|
-
}).commits.should eq(4)
|
326
|
-
end
|
327
|
-
|
328
|
-
it "should should possible a wide date span (include all)" do
|
329
|
-
GitFame::Base.new({
|
330
|
-
repository: repository,
|
331
|
-
after: "2000-01-01",
|
332
|
-
before: "2020-01-01"
|
333
|
-
}).commits.should eq(70)
|
334
|
-
end
|
335
|
-
|
336
|
-
it "should handle a too early 'after'" do
|
337
|
-
GitFame::Base.new({
|
338
|
-
repository: repository,
|
339
|
-
after: "2000-01-01",
|
340
|
-
before: "2008-08-31"
|
341
|
-
}).commits.should eq(1)
|
342
|
-
end
|
343
|
-
|
344
|
-
it "should catch empty commit span" do
|
345
|
-
lambda do
|
346
|
-
GitFame::Base.new({
|
347
|
-
repository: repository,
|
348
|
-
after: "2010-04-10",
|
349
|
-
before: "2010-04-11"
|
350
|
-
}).commits
|
351
|
-
end.should raise_error(GitFame::Error)
|
352
|
-
end
|
353
|
-
|
354
|
-
it "should handle a too late 'before'" do
|
355
|
-
GitFame::Base.new({
|
356
|
-
repository: repository,
|
357
|
-
after: "2012-02-29",
|
358
|
-
before: "2030-01-01"
|
359
|
-
}).commits.should eq(4)
|
360
|
-
end
|
361
|
-
|
362
|
-
it "should handle the after date same date as init commit" do
|
363
|
-
GitFame::Base.new({
|
364
|
-
repository: repository,
|
365
|
-
after: "2008-08-31",
|
366
|
-
before: "2008-09-03"
|
367
|
-
}).commits.should eq(5)
|
368
|
-
end
|
369
|
-
|
370
|
-
it "should handle an existing before with an old after" do
|
371
|
-
GitFame::Base.new({
|
372
|
-
repository: repository,
|
373
|
-
after: "2000-08-31",
|
374
|
-
before: "2008-09-03"
|
375
|
-
}).commits.should eq(5)
|
376
|
-
end
|
377
|
-
|
378
|
-
it "should handle an existing after with an old before" do
|
379
|
-
GitFame::Base.new({
|
380
|
-
repository: repository,
|
381
|
-
after: "2012-05-23",
|
382
|
-
before: "2020-01-01"
|
383
|
-
}).commits.should eq(1)
|
384
|
-
end
|
385
|
-
|
386
|
-
it "should raise an error if after > before" do
|
387
|
-
lambda do
|
388
|
-
GitFame::Base.new({
|
389
|
-
repository: repository,
|
390
|
-
after: "2020-01-01",
|
391
|
-
before: "2000-01-01"
|
392
|
-
}).commits
|
393
|
-
end.should raise_error(GitFame::Error)
|
394
|
-
end
|
395
|
-
|
396
|
-
it "should raise error if set too high" do
|
397
|
-
lambda do
|
398
|
-
GitFame::Base.new({
|
399
|
-
repository: repository,
|
400
|
-
after: "2030-01-01",
|
401
|
-
before: "2050-01-01"
|
402
|
-
}).commits
|
403
|
-
end.should raise_error(GitFame::Error)
|
404
|
-
end
|
405
|
-
|
406
|
-
it "should raise error if set too low" do
|
407
|
-
lambda do
|
408
|
-
GitFame::Base.new({
|
409
|
-
repository: repository,
|
410
|
-
after: "1990-01-01",
|
411
|
-
before: "2000-01-01"
|
412
|
-
}).commits
|
413
|
-
end.should raise_error(GitFame::Error)
|
414
|
-
end
|
415
|
-
|
416
|
-
it "should handle same day" do
|
417
|
-
GitFame::Base.new({
|
418
|
-
repository: repository,
|
419
|
-
after: "2012-02-29",
|
420
|
-
before: "2012-02-29"
|
421
|
-
}).commits.should eq(3)
|
422
|
-
end
|
423
|
-
|
424
|
-
it "should handle same day (HEAD)" do
|
425
|
-
GitFame::Base.new({
|
426
|
-
repository: repository,
|
427
|
-
after: "2012-05-23",
|
428
|
-
before: "2012-05-23"
|
429
|
-
}).commits.should eq(1)
|
430
|
-
end
|
431
|
-
|
432
|
-
it "should handle same day (last commit)" do
|
433
|
-
GitFame::Base.new({
|
434
|
-
repository: repository,
|
435
|
-
after: "2008-08-31",
|
436
|
-
before: "2008-08-31"
|
437
|
-
}).commits.should eq(1)
|
438
|
-
end
|
439
|
-
|
440
|
-
it "should handle a non existent 'after' date" do
|
441
|
-
GitFame::Base.new({
|
442
|
-
repository: repository,
|
443
|
-
after: "2008-09-02",
|
444
|
-
before: "2008-09-04"
|
445
|
-
}).commits.should eq(4)
|
446
|
-
end
|
447
|
-
|
448
|
-
it "should handle a non existent 'before' date" do
|
449
|
-
GitFame::Base.new({
|
450
|
-
repository: repository,
|
451
|
-
after: "2008-09-04",
|
452
|
-
before: "2008-09-05"
|
453
|
-
}).commits.should eq(3)
|
454
|
-
end
|
455
|
-
|
456
|
-
it "should handle both non existent 'before' and 'after'" do
|
457
|
-
GitFame::Base.new({
|
458
|
-
repository: repository,
|
459
|
-
after: "2008-09-02",
|
460
|
-
before: "2008-09-05"
|
461
|
-
}).commits.should eq(4)
|
462
|
-
end
|
463
|
-
end
|
464
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require "rspec"
|
2
|
-
require "git_fame"
|
3
|
-
require "coveralls"
|
4
|
-
require "rspec/collection_matchers"
|
5
|
-
require "rspec/expectations"
|
6
|
-
require "pp"
|
7
|
-
require_relative "./support/startup"
|
8
|
-
|
9
|
-
Coveralls.wear!
|
10
|
-
|
11
|
-
RSpec::Matchers.define :be_a_succees do
|
12
|
-
match do |actual|
|
13
|
-
actual.last
|
14
|
-
end
|
15
|
-
|
16
|
-
failure_message do |actual|
|
17
|
-
"expected command to be a success, but failed"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
RSpec::Matchers.define :include_output do |expected|
|
22
|
-
match do |actual|
|
23
|
-
actual.first.include?(expected)
|
24
|
-
end
|
25
|
-
|
26
|
-
failure_message do |actual|
|
27
|
-
"expected #{actual} to include #{expected}, but didn't"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.configure do |config|
|
32
|
-
# Set to false to allow Kernel#puts
|
33
|
-
suppress_stdout = true
|
34
|
-
|
35
|
-
config.include GitFame::Startup
|
36
|
-
config.mock_with :rspec
|
37
|
-
config.expect_with(:rspec) do |c|
|
38
|
-
c.syntax = [:should, :expect]
|
39
|
-
end
|
40
|
-
config.mock_with :rspec do |mocks|
|
41
|
-
mocks.syntax = :should
|
42
|
-
end
|
43
|
-
config.fail_fast = false
|
44
|
-
config.before(:all) do
|
45
|
-
Dir.chdir(repository) { system "git checkout 7ab01bc5a720 > /dev/null 2>&1" }
|
46
|
-
end
|
47
|
-
config.before(:suite) do
|
48
|
-
ENV["TZ"] = "GMT-2"
|
49
|
-
warn "-----------"
|
50
|
-
warn "Current environment:"
|
51
|
-
warn "\t#{`git --version`.strip}"
|
52
|
-
warn "\t#{`grep --version`.strip}"
|
53
|
-
warn "Spec notes:"
|
54
|
-
if suppress_stdout
|
55
|
-
warn "\tMessages to STDOUT has been suppressed. See spec/spec_helper.rb"
|
56
|
-
end
|
57
|
-
warn "\tRequires git 2.x for specs to pass"
|
58
|
-
warn "\tTime zone during testing is set to #{ENV["TZ"]}"
|
59
|
-
warn "-----------"
|
60
|
-
end
|
61
|
-
config.before(:each) do
|
62
|
-
$stdout.stub(:puts) if suppress_stdout
|
63
|
-
end
|
64
|
-
end
|
data/spec/support/startup.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require "open3"
|
2
|
-
|
3
|
-
module GitFame
|
4
|
-
module Startup
|
5
|
-
def repository
|
6
|
-
File.join(File.dirname(File.dirname(__FILE__)), "fixtures/gash")
|
7
|
-
end
|
8
|
-
|
9
|
-
def binary
|
10
|
-
File.join(File.dirname(File.dirname(__FILE__)), "../bin/git-fame")
|
11
|
-
end
|
12
|
-
|
13
|
-
def run(*args)
|
14
|
-
Open3.popen2e(*([binary] + args), chdir: repository) do |_, out, thread|
|
15
|
-
return [out.read, thread.value.success?]
|
16
|
-
end
|
17
|
-
rescue Errno::ENOENT
|
18
|
-
[$!.message, false]
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|