git_statistics 0.7.0 → 0.8.0
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.
- checksums.yaml +4 -4
- data/bin/git-statistics +1 -1
- data/bin/git_statistics +1 -1
- data/lib/git_statistics.rb +33 -35
- data/lib/git_statistics/collector.rb +13 -16
- data/lib/git_statistics/commit_summary.rb +13 -16
- data/lib/git_statistics/commits.rb +34 -36
- data/lib/git_statistics/diff_summary.rb +13 -17
- data/lib/git_statistics/formatters/console.rb +22 -18
- data/lib/git_statistics/log.rb +3 -5
- data/lib/git_statistics/pipe.rb +1 -1
- data/lib/git_statistics/utilities.rb +7 -9
- data/lib/git_statistics/version.rb +1 -1
- data/spec/collector_spec.rb +107 -104
- data/spec/commit_summary_spec.rb +110 -84
- data/spec/commits_spec.rb +251 -218
- data/spec/formatters/console_spec.rb +141 -127
- data/spec/log_spec.rb +19 -21
- data/spec/pipe_spec.rb +30 -25
- data/spec/utilities_spec.rb +42 -40
- metadata +37 -37
@@ -1,7 +1,6 @@
|
|
1
1
|
module GitStatistics
|
2
2
|
module Formatters
|
3
3
|
class Console
|
4
|
-
|
5
4
|
attr_reader :output
|
6
5
|
attr_accessor :commits, :config
|
7
6
|
|
@@ -17,15 +16,15 @@ module GitStatistics
|
|
17
16
|
|
18
17
|
# Acquire data based on sort type and top # to show
|
19
18
|
data = @commits.author_top_n_type(sort.to_sym, top_n)
|
20
|
-
raise
|
19
|
+
raise 'Parameter for --sort is not valid' if data.nil?
|
21
20
|
|
22
21
|
# Create config
|
23
|
-
@config = {:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
@config = { data: data,
|
23
|
+
author_length: Utilities.max_length_in_list(data.keys, 17),
|
24
|
+
language_length: Utilities.max_length_in_list(@commits.totals[:languages].keys, 8),
|
25
|
+
sort: sort,
|
26
|
+
email: email,
|
27
|
+
top_n: top_n }
|
29
28
|
|
30
29
|
# Acquire formatting pattern for output
|
31
30
|
@pattern = "| %-#{config[:author_length]}s | %-#{config[:language_length]}s | %7s | %9s | %9s | %7s | %7s | %7s | %6s | %6s |"
|
@@ -39,14 +38,19 @@ module GitStatistics
|
|
39
38
|
|
40
39
|
# Print query/header information
|
41
40
|
print_header
|
41
|
+
|
42
42
|
# Print per author information
|
43
43
|
config[:data].each do |name, commit_data|
|
44
44
|
print_row(name, commit_data)
|
45
45
|
print_language_data(commit_data)
|
46
46
|
end
|
47
|
+
|
47
48
|
add_row separator
|
48
|
-
|
49
|
+
|
50
|
+
print_row('Repository Totals', commit_totals)
|
49
51
|
print_language_data(commit_totals)
|
52
|
+
add_row separator
|
53
|
+
|
50
54
|
display!
|
51
55
|
end
|
52
56
|
|
@@ -56,24 +60,24 @@ module GitStatistics
|
|
56
60
|
|
57
61
|
def print_language_data(data)
|
58
62
|
# Print information of each language for the data
|
59
|
-
data[:languages].each do |language, commit_data|
|
60
|
-
print_row(
|
63
|
+
data[:languages].sort.each do |language, commit_data|
|
64
|
+
print_row('', commit_data, language)
|
61
65
|
end
|
62
66
|
output
|
63
67
|
end
|
64
68
|
|
65
69
|
def print_row(name, commit_info, language = '')
|
66
70
|
add_row format_for_row(name, language, commit_info[:commits],
|
67
|
-
|
68
|
-
|
71
|
+
commit_info[:additions], commit_info[:deletions], commit_info[:added_files],
|
72
|
+
commit_info[:deleted_files], commit_info[:renamed_files], commit_info[:copied_files], commit_info[:merges])
|
69
73
|
end
|
70
74
|
|
71
75
|
def print_header
|
72
|
-
|
73
|
-
|
76
|
+
author_info(@commits.stats.size)
|
77
|
+
header_info
|
74
78
|
end
|
75
79
|
|
76
|
-
def
|
80
|
+
def header_info
|
77
81
|
add_row separator
|
78
82
|
add_row format_for_row('Name/Email', 'Language', 'Commits', 'Additions', 'Deletions', 'Creates', 'Deletes', 'Renames', 'Copies', 'Merges')
|
79
83
|
add_row separator
|
@@ -84,10 +88,10 @@ module GitStatistics
|
|
84
88
|
end
|
85
89
|
|
86
90
|
def separator
|
87
|
-
(
|
91
|
+
('-' * 89) + ('-' * config[:author_length]) + ('-' * config[:language_length])
|
88
92
|
end
|
89
93
|
|
90
|
-
def
|
94
|
+
def author_info(total_authors)
|
91
95
|
if config[:top_n] > 0 && config[:top_n] < total_authors
|
92
96
|
add_row "Top #{config[:top_n]} authors(#{total_authors}) sorted by #{config[:sort]}"
|
93
97
|
else
|
data/lib/git_statistics/log.rb
CHANGED
@@ -8,7 +8,7 @@ module GitStatistics
|
|
8
8
|
attr_accessor :logger, :base_directory, :debugging
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@base_directory = File.expand_path(
|
11
|
+
@base_directory = File.expand_path('../..', __FILE__) + '/'
|
12
12
|
@debugging = false
|
13
13
|
@logger = Logger.new(STDOUT)
|
14
14
|
@logger.level = Logger::ERROR
|
@@ -29,8 +29,7 @@ module GitStatistics
|
|
29
29
|
if /^(?<file>.+?):(?<line>\d+)(?::in `(?<method>.*)')?/ =~ message
|
30
30
|
file = Regexp.last_match[:file]
|
31
31
|
line = Regexp.last_match[:line]
|
32
|
-
|
33
|
-
"#{file.sub(instance.base_directory, "")}:#{line}"
|
32
|
+
"#{file.sub(instance.base_directory, '')}:#{line}"
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
@@ -43,7 +42,7 @@ module GitStatistics
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
def self.respond_to_missing?(method, include_all=false)
|
45
|
+
def self.respond_to_missing?(method, include_all = false)
|
47
46
|
if valid_method? method
|
48
47
|
true
|
49
48
|
else
|
@@ -54,6 +53,5 @@ module GitStatistics
|
|
54
53
|
def self.valid_method?(method)
|
55
54
|
instance.logger.respond_to? method
|
56
55
|
end
|
57
|
-
|
58
56
|
end
|
59
57
|
end
|
data/lib/git_statistics/pipe.rb
CHANGED
@@ -2,22 +2,21 @@ require 'rbconfig'
|
|
2
2
|
|
3
3
|
module GitStatistics
|
4
4
|
module Utilities
|
5
|
-
|
6
5
|
def self.max_length_in_list(list, min_length = nil)
|
7
6
|
list ||= []
|
8
7
|
min_length = min_length.to_i
|
9
|
-
list_max = list.map { |k,_| k.length }.max || 0
|
8
|
+
list_max = list.map { |k, _| k.length }.max || 0
|
10
9
|
list_max >= min_length ? list_max : min_length
|
11
10
|
end
|
12
11
|
|
13
12
|
COMMANDS = {
|
14
|
-
:
|
15
|
-
:
|
13
|
+
windows: -> { raise '`stat` is not supported on Windows' },
|
14
|
+
mac: -> { '-f %m' }
|
16
15
|
}
|
17
|
-
COMMANDS.default = ->{
|
16
|
+
COMMANDS.default = -> { '-c %Y' }
|
18
17
|
|
19
18
|
def self.get_modified_time(file)
|
20
|
-
flags = COMMANDS[os].
|
19
|
+
flags = COMMANDS[os].call
|
21
20
|
time_at("stat #{flags} #{file}")
|
22
21
|
end
|
23
22
|
|
@@ -31,12 +30,12 @@ module GitStatistics
|
|
31
30
|
OPERATING_SYSTEMS.default = :unknown
|
32
31
|
|
33
32
|
def self.determine(os_name)
|
34
|
-
OPERATING_SYSTEMS.
|
33
|
+
OPERATING_SYSTEMS.find { |k, _| k =~ os_name }
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
37
|
def self.time_at(cmd)
|
39
|
-
Time.at(
|
38
|
+
Time.at(`#{cmd}`.to_i)
|
40
39
|
end
|
41
40
|
|
42
41
|
def self.os
|
@@ -49,6 +48,5 @@ module GitStatistics
|
|
49
48
|
Log.error "No such directory #{File.expand_path(directory)}"
|
50
49
|
0
|
51
50
|
end
|
52
|
-
|
53
51
|
end
|
54
52
|
end
|
data/spec/collector_spec.rb
CHANGED
@@ -2,124 +2,127 @@ require 'spec_helper'
|
|
2
2
|
include GitStatistics
|
3
3
|
|
4
4
|
describe Collector do
|
5
|
-
let(:limit) {100}
|
6
|
-
let(:fresh) {true}
|
7
|
-
let(:pretty) {false}
|
5
|
+
let(:limit) { 100 }
|
6
|
+
let(:fresh) { true }
|
7
|
+
let(:pretty) { false }
|
8
8
|
let(:repo) { GIT_REPO }
|
9
|
-
let(:collector) {Collector.new(repo, limit, fresh, pretty)}
|
10
|
-
|
11
|
-
describe
|
12
|
-
let(:branch) {CLI::DEFAULT_BRANCH}
|
13
|
-
let(:email) {false}
|
14
|
-
let(:merge) {true}
|
15
|
-
let(:time_since) {
|
16
|
-
let(:time_until) {
|
17
|
-
let(:author) {
|
18
|
-
|
19
|
-
|
20
|
-
collector.collect(
|
9
|
+
let(:collector) { Collector.new(repo, limit, fresh, pretty) }
|
10
|
+
|
11
|
+
describe '#collect' do
|
12
|
+
let(:branch) { CLI::DEFAULT_BRANCH }
|
13
|
+
let(:email) { false }
|
14
|
+
let(:merge) { true }
|
15
|
+
let(:time_since) { 'Tue Sep 24 14:15:44 2012 -0400' }
|
16
|
+
let(:time_until) { 'Tue Sep 26 14:45:05 2012 -0400' }
|
17
|
+
let(:author) { 'Kevin Jalbert' }
|
18
|
+
|
19
|
+
subject do
|
20
|
+
collector.collect(branch: branch, time_since: time_since, time_until: time_until)
|
21
21
|
collector.commits.calculate_statistics(email, merge)
|
22
|
-
|
23
|
-
}
|
24
|
-
|
25
|
-
context "with no merge commits" do
|
26
|
-
let(:merge) {false}
|
27
|
-
let(:time_since) {"Tue Sep 10 14:15:44 2012 -0400"}
|
28
|
-
let(:time_until) {"Tue Sep 11 14:45:05 2012 -0400"}
|
29
|
-
|
30
|
-
before(:all) { setup }
|
31
|
-
|
32
|
-
it{@subject[:additions].should == 276}
|
33
|
-
it{@subject[:deletions].should == 99}
|
34
|
-
it{@subject[:commits].should == 4}
|
35
|
-
it{@subject[:merges].should == 0}
|
36
|
-
|
37
|
-
it{@subject[:languages][:Ruby][:additions].should == 270}
|
38
|
-
it{@subject[:languages][:Ruby][:deletions].should == 99}
|
39
|
-
it{@subject[:languages][:Ruby][:added_files].should == 2}
|
40
|
-
it{@subject[:languages][:Text][:additions].should == 6}
|
41
|
-
it{@subject[:languages][:Text][:deletions].should == 0}
|
42
|
-
it{@subject[:languages][:Text][:added_files].should == 1}
|
22
|
+
collector.commits.stats[author]
|
43
23
|
end
|
44
24
|
|
45
|
-
context
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
it
|
51
|
-
|
25
|
+
context 'with no merge commits' do
|
26
|
+
let(:merge) { false }
|
27
|
+
let(:time_since) { 'Tue Sep 10 14:15:44 2012 -0400' }
|
28
|
+
let(:time_until) { 'Tue Sep 11 14:45:05 2012 -0400' }
|
29
|
+
|
30
|
+
it do
|
31
|
+
expect(subject[:additions]).to eq(276)
|
32
|
+
expect(subject[:deletions]).to eq(99)
|
33
|
+
expect(subject[:commits]).to eq(4)
|
34
|
+
expect(subject[:merges]).to eq(0)
|
35
|
+
|
36
|
+
expect(subject[:languages][:Ruby][:additions]).to eq(270)
|
37
|
+
expect(subject[:languages][:Ruby][:deletions]).to eq(99)
|
38
|
+
expect(subject[:languages][:Ruby][:added_files]).to eq(2)
|
39
|
+
expect(subject[:languages][:Text][:additions]).to eq(6)
|
40
|
+
expect(subject[:languages][:Text][:deletions]).to eq(0)
|
41
|
+
expect(subject[:languages][:Text][:added_files]).to eq(1)
|
42
|
+
end
|
43
|
+
end
|
52
44
|
|
53
|
-
|
54
|
-
it
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
45
|
+
context 'with merge commits and merge option' do
|
46
|
+
it do
|
47
|
+
expect(subject[:additions]).to eq(1240)
|
48
|
+
expect(subject[:deletions]).to eq(934)
|
49
|
+
expect(subject[:commits]).to eq(9)
|
50
|
+
expect(subject[:merges]).to eq(1)
|
51
|
+
|
52
|
+
expect(subject[:languages][:Markdown][:additions]).to eq(1)
|
53
|
+
expect(subject[:languages][:Markdown][:deletions]).to eq(0)
|
54
|
+
expect(subject[:languages][:Ruby][:additions]).to eq(1227)
|
55
|
+
expect(subject[:languages][:Ruby][:deletions]).to eq(934)
|
56
|
+
expect(subject[:languages][:Unknown][:additions]).to eq(12)
|
57
|
+
expect(subject[:languages][:Unknown][:deletions]).to eq(0)
|
58
|
+
end
|
59
59
|
end
|
60
60
|
|
61
|
-
context
|
62
|
-
let(:merge) {false}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
61
|
+
context 'with merge commits and no merge option' do
|
62
|
+
let(:merge) { false }
|
63
|
+
|
64
|
+
it do
|
65
|
+
expect(subject[:additions]).to eq(581)
|
66
|
+
expect(subject[:deletions]).to eq(452)
|
67
|
+
expect(subject[:commits]).to eq(8)
|
68
|
+
expect(subject[:merges]).to eq(0)
|
69
|
+
|
70
|
+
expect(subject[:languages][:Markdown][:additions]).to eq(1)
|
71
|
+
expect(subject[:languages][:Markdown][:deletions]).to eq(0)
|
72
|
+
expect(subject[:languages][:Ruby][:additions]).to eq(574)
|
73
|
+
expect(subject[:languages][:Ruby][:deletions]).to eq(452)
|
74
|
+
expect(subject[:languages][:Unknown][:additions]).to eq(6)
|
75
|
+
expect(subject[:languages][:Unknown][:deletions]).to eq(0)
|
76
|
+
end
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
describe
|
80
|
-
let(:commit) {repo.lookup(sha)}
|
81
|
-
let(:data) {collector.extract_commit(commit, nil)}
|
82
|
-
|
83
|
-
context
|
84
|
-
let(:sha) {
|
85
|
-
|
86
|
-
it
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
80
|
+
describe '#extract_commit' do
|
81
|
+
let(:commit) { repo.lookup(sha) }
|
82
|
+
let(:data) { collector.extract_commit(commit, nil) }
|
83
|
+
|
84
|
+
context 'with valid commit' do
|
85
|
+
let(:sha) { '260bc61e2c42930d91f3503c5849b0a2351275cf' }
|
86
|
+
|
87
|
+
it do
|
88
|
+
expect(data[:author]).to eq('Kevin Jalbert')
|
89
|
+
expect(data[:author_email]).to eq('kevin.j.jalbert@gmail.com')
|
90
|
+
expect(data[:time]).to match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-|+]\d{4}/)
|
91
|
+
|
92
|
+
expect(data[:merge]).to eq(false)
|
93
|
+
expect(data[:additions]).to eq(30)
|
94
|
+
expect(data[:deletions]).to eq(2)
|
95
|
+
expect(data[:added_files]).to eq(1)
|
96
|
+
expect(data[:deleted_files]).to eq(0)
|
97
|
+
|
98
|
+
expect(data[:files][0][:filename]).to eq('Gemfile')
|
99
|
+
expect(data[:files][0][:additions]).to eq(0)
|
100
|
+
expect(data[:files][0][:deletions]).to eq(1)
|
101
|
+
expect(data[:files][0][:status]).to eq(:modified)
|
102
|
+
expect(data[:files][0][:language]).to eq('Ruby')
|
103
|
+
|
104
|
+
expect(data[:files][1][:filename]).to eq('Gemfile.lock')
|
105
|
+
expect(data[:files][1][:additions]).to eq(30)
|
106
|
+
expect(data[:files][1][:deletions]).to eq(0)
|
107
|
+
expect(data[:files][1][:status]).to eq(:added)
|
108
|
+
expect(data[:files][1][:language]).to eq('Unknown')
|
109
|
+
|
110
|
+
expect(data[:files][2][:filename]).to eq('lib/git_statistics/initialize.rb')
|
111
|
+
expect(data[:files][2][:additions]).to eq(0)
|
112
|
+
expect(data[:files][2][:deletions]).to eq(1)
|
113
|
+
expect(data[:files][2][:status]).to eq(:modified)
|
114
|
+
expect(data[:files][2][:language]).to eq('Ruby')
|
115
|
+
end
|
112
116
|
end
|
113
117
|
|
114
|
-
context
|
115
|
-
let(:sha) {
|
116
|
-
it { expect {data}.to raise_error(Rugged::OdbError) }
|
118
|
+
context 'with invalid commit' do
|
119
|
+
let(:sha) { '111111aa111a11111a11aa11aaaa11a111111a11' }
|
120
|
+
it { expect { data }.to raise_error(Rugged::OdbError) }
|
117
121
|
end
|
118
122
|
|
119
|
-
context
|
120
|
-
let(:sha) {
|
121
|
-
it { expect {data}.to raise_error(Rugged::InvalidError) }
|
123
|
+
context 'with invalid sha' do
|
124
|
+
let(:sha) { 'invalid input' }
|
125
|
+
it { expect { data }.to raise_error(Rugged::InvalidError) }
|
122
126
|
end
|
123
127
|
end
|
124
|
-
|
125
128
|
end
|
data/spec/commit_summary_spec.rb
CHANGED
@@ -2,125 +2,151 @@ require 'spec_helper'
|
|
2
2
|
include GitStatistics
|
3
3
|
|
4
4
|
describe CommitSummary do
|
5
|
-
|
6
|
-
let(:sha) { "bf09a64b0e0f801d3e7fe4e002cbd1bf517340a7" }
|
5
|
+
let(:sha) { 'bf09a64b0e0f801d3e7fe4e002cbd1bf517340a7' }
|
7
6
|
let(:repo) { GIT_REPO }
|
8
7
|
subject(:commit) { CommitSummary.new(repo, repo.lookup(sha)) }
|
9
8
|
|
10
|
-
|
9
|
+
it { expect(subject.__getobj__).to be_a(Rugged::Commit) }
|
11
10
|
|
12
|
-
context
|
13
|
-
|
14
|
-
|
11
|
+
context 'understands its files and languages' do
|
12
|
+
it do
|
13
|
+
expect(subject.filenames.size).to eq(3)
|
14
|
+
expect(subject.languages.size).to eq(1)
|
15
|
+
end
|
15
16
|
end
|
16
17
|
|
17
|
-
context
|
18
|
-
let(:name) {
|
19
|
-
subject(:language) { commit.languages.
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
context 'language-specific changes' do
|
19
|
+
let(:name) { 'Ruby' }
|
20
|
+
subject(:language) { commit.languages.find { |lang| lang.name == name } }
|
21
|
+
|
22
|
+
context 'for commit 2aa45e4ff23c1a558b127c06e95d313a56cc6890' do
|
23
|
+
let(:sha) { '2aa45e4ff23c1a558b127c06e95d313a56cc6890' }
|
24
|
+
|
25
|
+
context 'language count' do
|
26
|
+
it { expect(commit.languages.size).to eq(2) }
|
25
27
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
|
29
|
+
context 'Ruby' do
|
30
|
+
let(:name) { 'Ruby' }
|
31
|
+
it do
|
32
|
+
expect(subject.additions).to eq(14)
|
33
|
+
expect(subject.deletions).to eq(13)
|
34
|
+
expect(subject.net).to eq(1)
|
35
|
+
end
|
31
36
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
+
|
38
|
+
context 'Text' do
|
39
|
+
let(:name) { 'Text' }
|
40
|
+
it do
|
41
|
+
expect(subject.additions).to eq(7)
|
42
|
+
expect(subject.deletions).to eq(11)
|
43
|
+
expect(subject.net).to eq(-4)
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
39
|
-
|
47
|
+
|
48
|
+
context 'for commit bf09a64b' do
|
40
49
|
subject { commit.languages.first }
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
50
|
+
it do
|
51
|
+
expect(subject.name).to eq('Ruby')
|
52
|
+
expect(subject.additions).to eq(10)
|
53
|
+
expect(subject.deletions).to eq(27)
|
54
|
+
expect(subject.net).to eq(-17)
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
47
58
|
|
48
|
-
context
|
49
|
-
let(:name) {
|
50
|
-
subject(:file) { commit.file_stats.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
59
|
+
context 'file-specific changes' do
|
60
|
+
let(:name) { 'lib/git_statistics/formatters/console.rb' }
|
61
|
+
subject(:file) { commit.file_stats.find { |file| file.filename == name } }
|
62
|
+
|
63
|
+
context 'for commit ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd' do
|
64
|
+
let(:sha) { 'ef9292a92467430e0061e1b1ad4cbbc3ad7da6fd' }
|
65
|
+
|
66
|
+
context 'file count' do
|
67
|
+
it { expect(commit.filenames.size).to eq(12) }
|
56
68
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
69
|
+
|
70
|
+
context 'bin/git_statistics (new)' do
|
71
|
+
let(:name) { 'bin/git_statistics' }
|
72
|
+
it do
|
73
|
+
expect(subject.language).to eq('Ruby')
|
74
|
+
expect(subject.additions).to eq(5)
|
75
|
+
expect(subject.deletions).to eq(0)
|
76
|
+
expect(subject.net).to eq(5)
|
77
|
+
expect(subject.status).to eq(:added)
|
78
|
+
end
|
64
79
|
end
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
80
|
+
|
81
|
+
context 'lib/initialize.rb (deleted)' do
|
82
|
+
let(:name) { 'lib/initialize.rb' }
|
83
|
+
it do
|
84
|
+
expect(subject.language).to eq('Ruby')
|
85
|
+
expect(subject.additions).to eq(0)
|
86
|
+
expect(subject.deletions).to eq(4)
|
87
|
+
expect(subject.net).to eq(-4)
|
88
|
+
expect(subject.status).to eq(:deleted)
|
89
|
+
end
|
72
90
|
end
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
91
|
+
|
92
|
+
context 'lib/git_statistics.rb (modified)' do
|
93
|
+
let(:name) { 'lib/git_statistics.rb' }
|
94
|
+
it do
|
95
|
+
expect(subject.language).to eq('Ruby')
|
96
|
+
expect(subject.additions).to eq(37)
|
97
|
+
expect(subject.deletions).to eq(30)
|
98
|
+
expect(subject.net).to eq(7)
|
99
|
+
expect(subject.status).to eq(:modified)
|
100
|
+
end
|
80
101
|
end
|
81
102
|
end
|
82
103
|
end
|
83
104
|
|
84
|
-
context
|
85
|
-
let(:sha) {
|
86
|
-
|
105
|
+
context 'with a removed file' do
|
106
|
+
let(:sha) { '4ce86b844458a1fd77c6066c9297576b9520f97e' }
|
107
|
+
it { expect(subject.deleted_files).to eq(2) }
|
87
108
|
end
|
88
109
|
|
89
|
-
context
|
90
|
-
let(:sha) {
|
91
|
-
|
110
|
+
context 'without a removed file' do
|
111
|
+
let(:sha) { 'b808b3a9d4ce2d8a1d850f2c24d2d1fb00e67727' }
|
112
|
+
it { expect(subject.deleted_files).to eq(0) }
|
92
113
|
end
|
93
114
|
|
94
|
-
context
|
95
|
-
let(:sha) {
|
96
|
-
|
115
|
+
context 'with a new file' do
|
116
|
+
let(:sha) { '8b1941437a0ff8cf6a35a46d4f5df8b6587c346f' }
|
117
|
+
it { expect(subject.added_files).to eq(19) }
|
97
118
|
end
|
98
119
|
|
99
|
-
context
|
100
|
-
let(:sha) {
|
101
|
-
|
120
|
+
context 'without a new file' do
|
121
|
+
let(:sha) { '52f9f38cbe4ba90edd607298cb2f9b1aec26bcf1' }
|
122
|
+
it { expect(subject.added_files).to eq(0) }
|
102
123
|
end
|
103
124
|
|
104
|
-
context
|
105
|
-
let(:sha) {
|
125
|
+
context 'with a merge' do
|
126
|
+
let(:sha) { '9d31467f6759c92f8535038c470d24a37ae93a9d' }
|
127
|
+
|
106
128
|
it { should be_a_merge }
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
129
|
+
|
130
|
+
context 'statistics' do
|
131
|
+
it do
|
132
|
+
expect(subject.filenames.size).to eq(11)
|
133
|
+
expect(subject.languages.size).to eq(1)
|
134
|
+
expect(subject.additions).to eq(69)
|
135
|
+
expect(subject.deletions).to eq(68)
|
136
|
+
expect(subject.net).to eq(1)
|
137
|
+
end
|
113
138
|
end
|
114
139
|
end
|
115
140
|
|
116
|
-
context
|
141
|
+
context 'without a merge' do
|
117
142
|
it { should_not be_a_merge }
|
118
143
|
end
|
119
144
|
|
120
|
-
context
|
121
|
-
|
122
|
-
|
123
|
-
|
145
|
+
context 'net, additions, and deletions' do
|
146
|
+
it do
|
147
|
+
expect(subject.additions).to eq(10)
|
148
|
+
expect(subject.deletions).to eq(27)
|
149
|
+
expect(subject.net).to eq(-17)
|
150
|
+
end
|
124
151
|
end
|
125
|
-
|
126
152
|
end
|