git_analysis 0.0.1.2 → 0.0.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 +23 -2
- data/bin/git-analysis +4 -3
- data/lib/git_analysis/version.rb +1 -1
- data/lib/git_analysis.rb +37 -2
- 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: 20d2cf9257f65553a99f093ed87ab95b54f6cc50
|
4
|
+
data.tar.gz: f97582d793741002e2766ca967281e3aa4136672
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20f0882da6026806f1932a0bb4436ab0cfae7d4b95a0e082e7a62753392cc5592743262f8c2c376f0e3cde453551e117716b6dd87dc9c8f807193deeb7af2a82
|
7
|
+
data.tar.gz: e64295b927764850a513af55c1317f4394fc7cd88420cbe5391054d65c22c13e1daf642b9ac4a4d1bf81a796d5dffdf862beac383e63ded7417b1eda28d7c292
|
data/README.md
CHANGED
@@ -18,26 +18,47 @@ ruby 2.0.0p353
|
|
18
18
|
|
19
19
|
```
|
20
20
|
Commands:
|
21
|
-
git-analysis count [-d]
|
21
|
+
git-analysis count [-d][-l] # count. email-domain or line. please run `git-analysis help count`)
|
22
22
|
git-analysis help [COMMAND] # Describe available commands or one specific command
|
23
23
|
git-analysis version # show version
|
24
24
|
```
|
25
25
|
|
26
26
|
### Count E-mail Domain
|
27
27
|
|
28
|
-
(v0.0.1 is this mode only)
|
29
28
|
Count Author's Email Domain. In order to investigate the companies that are participating in this project.
|
30
29
|
If most domain is "gmail", this project is developed by private developers.
|
31
30
|
|
32
31
|
```sample
|
33
32
|
$ git clone git@github.com:volanja/git_analysis.git
|
34
33
|
$ cd git_analysis
|
34
|
+
|
35
35
|
$ git-analysis count -d |jq '.'
|
36
36
|
{
|
37
|
+
"total": 5,
|
37
38
|
"gmail.com": 5
|
38
39
|
}
|
39
40
|
```
|
40
41
|
|
42
|
+
total = `git log --pretty=oneline |wc -l`
|
43
|
+
|
44
|
+
### Count Addition & Deletion by Domain (add v0.0.2)
|
45
|
+
```
|
46
|
+
$ git-analysis count -l |jq '.'
|
47
|
+
{
|
48
|
+
"gmail.com": {
|
49
|
+
"addition": 290,
|
50
|
+
"deletion": 50
|
51
|
+
},
|
52
|
+
"total": {
|
53
|
+
"addition": 290,
|
54
|
+
"deletion": 50
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
note: sort by addition
|
59
|
+
```
|
60
|
+
|
61
|
+
|
41
62
|
## Contributing
|
42
63
|
|
43
64
|
1. Fork it ( https://github.com/volanja/git_analysis/fork )
|
data/bin/git-analysis
CHANGED
@@ -7,13 +7,14 @@ require 'thor'
|
|
7
7
|
|
8
8
|
class Cli < Thor
|
9
9
|
|
10
|
-
desc "count [-d]", "count
|
10
|
+
desc "count [-d][-l]", "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
|
+
option :"line", :type => :boolean, :aliases => '-l', :desc => "count insertion & deletion"
|
12
13
|
def count
|
13
14
|
if options[:domain]
|
14
15
|
GitAnalysis.count_domain
|
15
|
-
|
16
|
-
|
16
|
+
elsif options[:line]
|
17
|
+
GitAnalysis.count_diff
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
data/lib/git_analysis/version.rb
CHANGED
data/lib/git_analysis.rb
CHANGED
@@ -9,17 +9,35 @@ module GitAnalysis
|
|
9
9
|
# count domain
|
10
10
|
def self.count_domain()
|
11
11
|
repo = load_repo()
|
12
|
-
#domain = Array.new
|
13
12
|
count = Hash.new(0)
|
14
13
|
repo.walk(repo.last_commit).each do |commit|
|
15
14
|
# TODO more Faster
|
16
|
-
domain = commit.author[:email].gsub(/\A[a-zA-Z0-9\_
|
15
|
+
domain = commit.author[:email].gsub(/\A[a-zA-Z0-9\_\-\.\+ ]+@/,"").rstrip
|
17
16
|
count[:"#{domain}"] += 1
|
17
|
+
count[:"total"] += 1
|
18
18
|
end
|
19
19
|
sorted = count.sort_by{|a,b| -b }
|
20
20
|
puts Oj.dump(Hash[sorted], :mode => :compat)
|
21
21
|
end
|
22
22
|
|
23
|
+
def self.count_diff()
|
24
|
+
repo = load_repo()
|
25
|
+
count = Hash.new{|h,k| h[k] = Hash.new(0) }
|
26
|
+
repo.walk(repo.last_commit).each do |commit|
|
27
|
+
domain = commit.author[:email].gsub(/\A[a-zA-Z0-9\_\-\.\+ ]+@/,"").rstrip
|
28
|
+
diff = commit_diff(repo, commit)
|
29
|
+
|
30
|
+
count[:"#{domain}"][:"addition"] += diff[1].to_i
|
31
|
+
count[:"#{domain}"][:"deletion"] += diff[2].to_i
|
32
|
+
|
33
|
+
count[:"total"][:"addition"] += diff[1].to_i
|
34
|
+
count[:"total"][:"deletion"] += diff[2].to_i
|
35
|
+
end
|
36
|
+
# TODO more Faster! it takes 50 sec(10k / sec).
|
37
|
+
sorted = count.sort_by{|a,b| -b[:"addition"] }
|
38
|
+
puts Oj.dump(Hash[sorted], :mode => :compat)
|
39
|
+
end
|
40
|
+
|
23
41
|
# export
|
24
42
|
def self.export()
|
25
43
|
repo = load_repo()
|
@@ -49,4 +67,21 @@ module GitAnalysis
|
|
49
67
|
exit 1
|
50
68
|
end
|
51
69
|
|
70
|
+
def self.commit_diff(repo,commit)
|
71
|
+
sha = String.new
|
72
|
+
sha_parents = String.new
|
73
|
+
diff_stat = Array.new
|
74
|
+
|
75
|
+
sha = commit.oid
|
76
|
+
unless commit.parents[0].nil?
|
77
|
+
sha_parents = commit.parents[0].oid
|
78
|
+
# Too Slow. More Faster
|
79
|
+
diff_stat = repo.diff(sha_parents,sha).stat
|
80
|
+
else
|
81
|
+
tmp = commit.diff.stat
|
82
|
+
diff_stat = [tmp[0], tmp[2], tmp[1]]
|
83
|
+
end
|
84
|
+
return diff_stat
|
85
|
+
end
|
86
|
+
|
52
87
|
end
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- volanja
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|