git_analysis 0.0.2 → 0.0.3
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/README.md +77 -9
- data/bin/git-analysis +4 -3
- data/lib/git_analysis.rb +47 -10
- data/lib/git_analysis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08645a52eaadeb1867565675437d912c6f2e9902
|
4
|
+
data.tar.gz: 8e05322c0bbbbb96e0938b3d57251056fabc677d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca59b4804e69e9e5d01fef1b7841af885d1dd6046d5d445689a011eb25fed9c5d4343a5700a884ba337e92f225784afd9146719694a10d9a4604672c5faa5554
|
7
|
+
data.tar.gz: 0f279e1d0a2e0683de45453e46939ae822c22af472dcfa7be94e0967f641d8984e0cefecb6fdd1f3c4bcfe4e3ca3a4147581bd75b8ad52c2871b63b8552c3bc0
|
data/README.md
CHANGED
@@ -34,30 +34,98 @@ $ cd git_analysis
|
|
34
34
|
|
35
35
|
$ git-analysis count -d |jq '.'
|
36
36
|
{
|
37
|
-
"
|
38
|
-
|
37
|
+
"count": {
|
38
|
+
"gmail.com": 14
|
39
|
+
},
|
40
|
+
"infomation": {
|
41
|
+
"last_commit_oid": "7bf2839121b1940c4999b187cd5717f9e94a4a85",
|
42
|
+
"last_commit_date": "2014-08-04 23:55:25 +0900",
|
43
|
+
"total_commit": 14
|
44
|
+
}
|
39
45
|
}
|
40
|
-
```
|
41
46
|
|
42
47
|
total = `git log --pretty=oneline |wc -l`
|
48
|
+
```
|
49
|
+
### Count E-mail Domain (topN add v0.0.3)
|
50
|
+
if N = 1, display most domain. and others is `total_commit - top1_commit`
|
51
|
+
|
52
|
+
```
|
53
|
+
$ git clone https://github.com/libgit2/rugged.git
|
54
|
+
$ cd rugged
|
55
|
+
|
56
|
+
$ git-analysis count -d -n 2 |jq '.'
|
57
|
+
{
|
58
|
+
"count": {
|
59
|
+
"gmail.com": 882,
|
60
|
+
"googlemail.com": 453,
|
61
|
+
"others": 437
|
62
|
+
},
|
63
|
+
"infomation": {
|
64
|
+
"last_commit_oid": "e96d26174b2bf763e9dd5dd2370e79f5e29077c9",
|
65
|
+
"last_commit_date": "2014-07-23 20:16:10 +0900",
|
66
|
+
"total_commit": 1772
|
67
|
+
}
|
68
|
+
}
|
69
|
+
```
|
70
|
+
|
43
71
|
|
44
72
|
### Count Addition & Deletion by Domain (add v0.0.2)
|
45
73
|
```
|
46
74
|
$ git-analysis count -l |jq '.'
|
47
75
|
{
|
48
|
-
"
|
49
|
-
"
|
50
|
-
|
76
|
+
"count": {
|
77
|
+
"gmail.com": {
|
78
|
+
"addition": 364,
|
79
|
+
"deletion": 74
|
80
|
+
}
|
51
81
|
},
|
52
|
-
"
|
53
|
-
"
|
54
|
-
"
|
82
|
+
"infomation": {
|
83
|
+
"last_commit_oid": "022403ad80ee7b22231e40f9a3679a019d5439f6",
|
84
|
+
"last_commit_date": "2014-08-06 00:02:01 +0900",
|
85
|
+
"total_commit": {
|
86
|
+
"addition": 364,
|
87
|
+
"deletion": 74
|
88
|
+
}
|
55
89
|
}
|
56
90
|
}
|
57
91
|
|
58
92
|
note: sort by addition
|
59
93
|
```
|
60
94
|
|
95
|
+
### Count Addition & Deletion by Domain (topN add v0.0.3)
|
96
|
+
if N = 1, display most domain. and others is `total_commit(add/del) - top1_commit(add/del)`
|
97
|
+
|
98
|
+
```
|
99
|
+
$ git clone https://github.com/libgit2/rugged.git
|
100
|
+
$ cd rugged
|
101
|
+
|
102
|
+
$ git-analysis count -l -n 2 |jq '.'
|
103
|
+
{
|
104
|
+
"count": {
|
105
|
+
"gmail.com": {
|
106
|
+
"addition": 32308,
|
107
|
+
"deletion": 15641
|
108
|
+
},
|
109
|
+
"googlemail.com": {
|
110
|
+
"addition": 17668,
|
111
|
+
"deletion": 7277
|
112
|
+
},
|
113
|
+
"others": {
|
114
|
+
"addition": 21768,
|
115
|
+
"deletion": 7098
|
116
|
+
}
|
117
|
+
},
|
118
|
+
"infomation": {
|
119
|
+
"last_commit_oid": "e96d26174b2bf763e9dd5dd2370e79f5e29077c9",
|
120
|
+
"last_commit_date": "2014-07-23 20:16:10 +0900",
|
121
|
+
"total_commit": {
|
122
|
+
"addition": 71744,
|
123
|
+
"deletion": 30016
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
```
|
128
|
+
|
61
129
|
|
62
130
|
## Contributing
|
63
131
|
|
data/bin/git-analysis
CHANGED
@@ -7,14 +7,15 @@ require 'thor'
|
|
7
7
|
|
8
8
|
class Cli < Thor
|
9
9
|
|
10
|
-
desc "count [-d][-l]", "count. email-domain or line. please run `git-analysis help count`)"
|
10
|
+
desc "count [-d][-l][-n]", "count. email-domain or line. please run `git-analysis help count`)"
|
11
11
|
option :"domain", :type => :boolean, :aliases => '-d', :desc => "count e-mail domain. export json"
|
12
12
|
option :"line", :type => :boolean, :aliases => '-l', :desc => "count insertion & deletion"
|
13
|
+
option :"number", :type => :numeric, :aliases => '-n', :desc => "topN."
|
13
14
|
def count
|
14
15
|
if options[:domain]
|
15
|
-
GitAnalysis.count_domain
|
16
|
+
GitAnalysis.count_domain(options[:number])
|
16
17
|
elsif options[:line]
|
17
|
-
GitAnalysis.count_diff
|
18
|
+
GitAnalysis.count_diff(options[:number])
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
data/lib/git_analysis.rb
CHANGED
@@ -7,22 +7,35 @@ require "oj"
|
|
7
7
|
module GitAnalysis
|
8
8
|
|
9
9
|
# count domain
|
10
|
-
def self.count_domain()
|
10
|
+
def self.count_domain(number=0)
|
11
11
|
repo = load_repo()
|
12
12
|
count = Hash.new(0)
|
13
|
+
total = 0
|
13
14
|
repo.walk(repo.last_commit).each do |commit|
|
14
15
|
# TODO more Faster
|
15
16
|
domain = commit.author[:email].gsub(/\A[a-zA-Z0-9\_\-\.\+ ]+@/,"").rstrip
|
16
17
|
count[:"#{domain}"] += 1
|
17
|
-
|
18
|
+
total += 1
|
18
19
|
end
|
19
|
-
|
20
|
-
|
20
|
+
if number.nil?
|
21
|
+
sorted = count.sort_by{|a,b| -b }
|
22
|
+
else
|
23
|
+
sorted = count.sort_by{|a,b| -b }.first(number)
|
24
|
+
sum =0
|
25
|
+
sorted.each{|c| sum += c[1] }
|
26
|
+
sorted << [:others, total - sum]
|
27
|
+
end
|
28
|
+
result = Hash.new
|
29
|
+
result[:'count'] = Hash.new
|
30
|
+
result[:'count'] = Hash[sorted]
|
31
|
+
result[:'infomation'] = get_info(repo,total)
|
32
|
+
puts Oj.dump(result, :mode => :compat)
|
21
33
|
end
|
22
34
|
|
23
|
-
def self.count_diff()
|
35
|
+
def self.count_diff(number=0)
|
24
36
|
repo = load_repo()
|
25
37
|
count = Hash.new{|h,k| h[k] = Hash.new(0) }
|
38
|
+
total = Hash.new(0)
|
26
39
|
repo.walk(repo.last_commit).each do |commit|
|
27
40
|
domain = commit.author[:email].gsub(/\A[a-zA-Z0-9\_\-\.\+ ]+@/,"").rstrip
|
28
41
|
diff = commit_diff(repo, commit)
|
@@ -30,12 +43,29 @@ module GitAnalysis
|
|
30
43
|
count[:"#{domain}"][:"addition"] += diff[1].to_i
|
31
44
|
count[:"#{domain}"][:"deletion"] += diff[2].to_i
|
32
45
|
|
33
|
-
|
34
|
-
|
46
|
+
total[:"addition"] += diff[1].to_i
|
47
|
+
total[:"deletion"] += diff[2].to_i
|
35
48
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
49
|
+
if number.nil?
|
50
|
+
# TODO more Faster! it takes 50 sec(10k / sec).
|
51
|
+
sorted = count.sort_by{|a,b| -b[:"addition"] }
|
52
|
+
else
|
53
|
+
sorted = count.sort_by{|a,b| -b[:"addition"] }.first(number)
|
54
|
+
sum = Hash.new(0)
|
55
|
+
sorted.each{|c|
|
56
|
+
sum["addition"] += c[1][:"addition"]
|
57
|
+
sum["deletion"] += c[1][:"deletion"]
|
58
|
+
}
|
59
|
+
tmp = Hash.new(0)
|
60
|
+
tmp[:"addition"] = total[:"addition"] - sum["addition"]
|
61
|
+
tmp[:"deletion"] = total[:"deletion"] - sum["deletion"]
|
62
|
+
sorted << [:"others",tmp]
|
63
|
+
end
|
64
|
+
result = Hash.new
|
65
|
+
result[:'count'] = Hash.new
|
66
|
+
result[:'count'] = Hash[sorted]
|
67
|
+
result[:'infomation'] = get_info(repo,total)
|
68
|
+
puts Oj.dump(result, :mode => :compat)
|
39
69
|
end
|
40
70
|
|
41
71
|
# export
|
@@ -84,4 +114,11 @@ module GitAnalysis
|
|
84
114
|
return diff_stat
|
85
115
|
end
|
86
116
|
|
117
|
+
def self.get_info(repo,total)
|
118
|
+
info = Hash.new
|
119
|
+
info[:'last_commit_oid'] = repo.last_commit.oid
|
120
|
+
info[:'last_commit_date'] = repo.last_commit.time.to_s
|
121
|
+
info[:'total_commit'] = total
|
122
|
+
return info
|
123
|
+
end
|
87
124
|
end
|
data/lib/git_analysis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_analysis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- volanja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|