forked from rmm5t/tilda-bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-stats
executable file
·25 lines (20 loc) · 858 Bytes
/
git-stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby
# Borrowed from Jim Garvin
# http://github.com/coderifous/dotfiles/blob/master/bin/git-stats.rb
Authors = []
Format = "%20s %13s %12s %12s %10s\n"
printf(Format, *%w(Author files-changed insertions deletions net))
open("| git shortlog -s -n").each do |line|
Authors << line.sub(/^\s*\d+\s*/, '').chomp
end
Authors.each do |name|
files_changed = insertions = deletions = 0
open("| git log --shortstat --no-merges --author='#{name}' | grep 'files changed'").each do |line|
matchdata = line.match(/(\d+) files changed, (\d+) insertions.* (\d+) deletions/)
next unless matchdata
files_changed += matchdata[1].to_i
insertions += matchdata[2].to_i
deletions += matchdata[3].to_i
end
printf(Format, name, files_changed, insertions, "-#{deletions}", insertions - deletions) unless files_changed == 0
end