gitstatsakido 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -13
- data/bin/gitstats +2 -1
- data/gitstats.gemspec +0 -8
- data/lib/gitstats.rb +59 -15
- data/lib/gitstats/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efe2e1ed3118a95823a37ecee8d27323ddaebbaa
|
4
|
+
data.tar.gz: 3e4c648e0d26f06dc581f06c6306a91e59752e26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cad1093695028b49bc050a8c1eecb787ce3c4123a5e80db1026d4bbe333571a623405d5da5f81da37ded234b63f7e292feed5e182e2fcc5ddc6da235d71b262
|
7
|
+
data.tar.gz: b73f98bdfef25d65a934bdab4890b84e539a1a7068d45616ad4c4fb75297bf97710faceedadc0b8996d8fe821025a7784ca5389d6377f4ed488db2fe7a475d4a
|
data/README.md
CHANGED
@@ -6,23 +6,20 @@ TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
Install it to your local directory by running:
|
10
10
|
|
11
|
-
|
12
|
-
gem 'gitstats'
|
13
|
-
```
|
11
|
+
$ gem install gitstatsakido
|
14
12
|
|
15
|
-
|
13
|
+
## Example Usage and Output (run in a git directory)
|
16
14
|
|
17
|
-
$
|
15
|
+
~/ruby/gitstats $ gitstats
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
17
|
+
Author <lei@akidolabs.com>:
|
18
|
+
`Total # of commits: 14`
|
19
|
+
`Total # of files changed: 64`
|
20
|
+
`Total # of lines changed: 1117`
|
21
|
+
`# of inserts: 767`
|
22
|
+
`# of deletes: 350`
|
26
23
|
|
27
24
|
## Development
|
28
25
|
|
data/bin/gitstats
CHANGED
data/gitstats.gemspec
CHANGED
@@ -14,14 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "http://www.akidolabs.com"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
# # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
-
# # to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
-
# if spec.respond_to?(:metadata)
|
20
|
-
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
-
# else
|
22
|
-
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
-
# end
|
24
|
-
|
25
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
18
|
spec.executables = ["gitstats"]
|
27
19
|
spec.require_paths = ["lib"]
|
data/lib/gitstats.rb
CHANGED
@@ -6,7 +6,7 @@ module Gitstats
|
|
6
6
|
class Commit
|
7
7
|
def initialize(id, commit_text_chunk)
|
8
8
|
# ignore_files = []
|
9
|
-
ignore_files = ['.txt', '.
|
9
|
+
ignore_files = ['.txt', '.dat', '.csv', 'out', 'swp', '.class', '.pdf', '.html', '.versionsBackup']
|
10
10
|
@id = id
|
11
11
|
@text = commit_text_chunk
|
12
12
|
@ignore_add = 0
|
@@ -14,7 +14,14 @@ module Gitstats
|
|
14
14
|
@inserts = 0
|
15
15
|
@deletes = 0
|
16
16
|
@files = 0
|
17
|
+
minus_c = 0
|
18
|
+
plus_c = 0
|
19
|
+
minus_count = 0
|
20
|
+
plus_count = 0
|
17
21
|
commit_text_chunk.split(/\r?\n/).each do |line|
|
22
|
+
# if @id.index('12226') != nil
|
23
|
+
# puts line
|
24
|
+
# end
|
18
25
|
words = line.split()
|
19
26
|
if /Author: [^<]+<[^>]+>/.match(line)
|
20
27
|
# TODO use name instead of email
|
@@ -34,7 +41,10 @@ module Gitstats
|
|
34
41
|
@inserts -= @ignore_add
|
35
42
|
@deletes -= @ignore_del
|
36
43
|
@files = words[0].to_i
|
37
|
-
elsif / [^|]+
|
44
|
+
elsif / [^|]+\|[ ]+[0-9]+ [+-]+/.match(line)
|
45
|
+
if words[3] == '|'
|
46
|
+
words = words[2..-1]
|
47
|
+
end
|
38
48
|
file_name = words[0].split()[-1]
|
39
49
|
count = words[2].to_i
|
40
50
|
plus_count = 0
|
@@ -57,6 +67,7 @@ module Gitstats
|
|
57
67
|
if file_name[-1 * comp_length..-1] == ext
|
58
68
|
@ignore_add += plus_c
|
59
69
|
@ignore_del += minus_c
|
70
|
+
# puts "#{@id} #{@inserts} #{@deletes} #{plus_c} #{minus_c} #{minus_count} #{plus_count}"
|
60
71
|
break
|
61
72
|
end
|
62
73
|
end
|
@@ -65,7 +76,7 @@ module Gitstats
|
|
65
76
|
end
|
66
77
|
|
67
78
|
def print_info
|
68
|
-
puts "Commit: #{@id} Author: #{@author} Time: #{@time} Files changed: #{@files}"
|
79
|
+
puts "Commit: #{@id} Author: #{@author} Time: #{@time} Files changed: #{@files} Inserts #{@inserts} Deletes #{@deletes}"
|
69
80
|
end
|
70
81
|
|
71
82
|
def author()
|
@@ -84,6 +95,10 @@ module Gitstats
|
|
84
95
|
@deletes
|
85
96
|
end
|
86
97
|
|
98
|
+
def loc
|
99
|
+
@inserts + @deletes
|
100
|
+
end
|
101
|
+
|
87
102
|
def files
|
88
103
|
@files
|
89
104
|
end
|
@@ -133,6 +148,18 @@ module Gitstats
|
|
133
148
|
def total_deletes
|
134
149
|
@total_deletes
|
135
150
|
end
|
151
|
+
|
152
|
+
def print_commits_sorted
|
153
|
+
s = @commits.sort { |y, x| (x.inserts + x.deletes) <=> (y.inserts + y.deletes) }
|
154
|
+
total = 10
|
155
|
+
s.each do |c|
|
156
|
+
if total < 0
|
157
|
+
break
|
158
|
+
end
|
159
|
+
c.print_info
|
160
|
+
total -= 1
|
161
|
+
end
|
162
|
+
end
|
136
163
|
end
|
137
164
|
|
138
165
|
|
@@ -148,6 +175,7 @@ module Gitstats
|
|
148
175
|
elsif !error.empty?
|
149
176
|
@@result = 'Unknown error from git: ' + error
|
150
177
|
else
|
178
|
+
@@result = 'Running git log --stat -M'
|
151
179
|
commit_regex = /commit [a-z0-9]{40}\r?\n/
|
152
180
|
commits = output.enum_for(:scan, commit_regex).map { Regexp.last_match.begin(0) }
|
153
181
|
commits.each_with_index do |x, index|
|
@@ -161,25 +189,41 @@ module Gitstats
|
|
161
189
|
if auth_mapping.key?(commit_data.author)
|
162
190
|
commit_data.set_author(auth_mapping[commit_data.author])
|
163
191
|
end
|
192
|
+
if commit_data.author.index("andrew") != nil
|
193
|
+
puts @@authors[commit_data.author]
|
194
|
+
puts @@authors.keys
|
195
|
+
end
|
164
196
|
auth = commit_data.author
|
165
|
-
if
|
166
|
-
@@authors[auth].add_commit(commit_data)
|
167
|
-
else
|
197
|
+
if !@@authors.key?(auth)
|
168
198
|
@@authors[auth] = Author.new(auth)
|
169
199
|
end
|
200
|
+
@@authors[auth].add_commit(commit_data)
|
170
201
|
end
|
171
|
-
@@result = @@authors["<lei@akidolabs.com>"].total_commits
|
172
|
-
|
173
202
|
end
|
174
203
|
|
175
204
|
def print_info
|
176
|
-
@@
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
205
|
+
puts @@result, "\n"
|
206
|
+
if @@authors.size > 0
|
207
|
+
sorted_authors = @@authors.keys.sort { |y, x| @@authors[y].total_commits <=> @@authors[x].total_commits }
|
208
|
+
sorted_authors.each do |k|
|
209
|
+
v = @@authors[k]
|
210
|
+
puts "Author #{k}:"
|
211
|
+
puts " Total # of commits: #{v.total_commits}"
|
212
|
+
puts " Total # of files changed: #{v.total_files}"
|
213
|
+
puts " Total # of lines changed: #{v.total_lines}"
|
214
|
+
puts " # of inserts: #{v.total_inserts}"
|
215
|
+
puts " # of deletes: #{v.total_deletes}"
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
def print_commits
|
221
|
+
if @@authors.size > 0
|
222
|
+
puts "\nTop 10 commits by lines changed:"
|
223
|
+
@@authors.each do |k, v|
|
224
|
+
puts "\n#################\nAuthor #{k}:"
|
225
|
+
v.print_commits_sorted
|
226
|
+
end
|
183
227
|
end
|
184
228
|
end
|
185
229
|
end
|
data/lib/gitstats/version.rb
CHANGED