git_fame 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/git_fame.gemspec +2 -0
- data/lib/git_fame/author.rb +3 -2
- data/lib/git_fame/base.rb +53 -26
- data/lib/git_fame/version.rb +1 -1
- data/spec/git_fame_spec.rb +30 -9
- metadata +46 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04200942414c95c6ec6c73bd9c6274d974c4e4ab
|
4
|
+
data.tar.gz: 290528caaf2d7ea37a707177b1a4cfa54ffa3401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9138e9bde7548b928b85adaaf6a45b2821e055c8f77058cdceb01065390abb3b661c2e9a2f7e6edd2add5f6dfe8a49ce18c6bff129cb54a26b51af9d67b7aa
|
7
|
+
data.tar.gz: 4d8c8f0d4545b5f189179f9fc30f05cfd3ef62f6e3f37405f2903ce4972fef5f0c0baf8154c0aa010175b0e81fb301db8312d4d971c278b8224d3f8834404750
|
data/README.md
CHANGED
@@ -122,7 +122,7 @@ The list of authors may include what you perceive to be duplicate people. If a g
|
|
122
122
|
|
123
123
|
## Requirements
|
124
124
|
|
125
|
-
*GitFame*
|
125
|
+
*GitFame* should work on all Unix based operating system with Git installed.
|
126
126
|
|
127
127
|
## License
|
128
128
|
|
data/git_fame.gemspec
CHANGED
@@ -28,7 +28,9 @@ Generates data like:
|
|
28
28
|
gem.add_dependency("trollop")
|
29
29
|
gem.add_dependency("hirb")
|
30
30
|
gem.add_dependency("mimer_plus")
|
31
|
+
gem.add_dependency("string-scrub")
|
31
32
|
|
32
33
|
gem.add_development_dependency("rspec")
|
34
|
+
gem.add_development_dependency("rake")
|
33
35
|
gem.required_ruby_version = ">= 1.9.2"
|
34
36
|
end
|
data/lib/git_fame/author.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module GitFame
|
2
2
|
class Author
|
3
3
|
include GitFame::Helper
|
4
|
-
attr_accessor :name, :raw_files, :raw_commits,
|
4
|
+
attr_accessor :name, :raw_files, :raw_commits,
|
5
|
+
:raw_loc, :files_list, :file_type_counts
|
6
|
+
|
5
7
|
#
|
6
8
|
# @args Hash
|
7
9
|
#
|
@@ -36,6 +38,5 @@ module GitFame
|
|
36
38
|
def method_missing(m, *args, &block)
|
37
39
|
file_type_counts[m.to_s]
|
38
40
|
end
|
39
|
-
|
40
41
|
end
|
41
42
|
end
|
data/lib/git_fame/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "string-scrub"
|
2
|
+
|
1
3
|
module GitFame
|
2
4
|
class Base
|
3
5
|
include GitFame::Helper
|
@@ -6,7 +8,8 @@ module GitFame
|
|
6
8
|
# @args[:repository] String Absolute path to git repository
|
7
9
|
# @args[:sort] String What should #authors be sorted by?
|
8
10
|
# @args[:bytype] Boolean Should counts be grouped by file extension?
|
9
|
-
# @args[:exclude] String Comma-separated list of paths in the repo
|
11
|
+
# @args[:exclude] String Comma-separated list of paths in the repo
|
12
|
+
# which should be excluded
|
10
13
|
#
|
11
14
|
def initialize(args)
|
12
15
|
@sort = "loc"
|
@@ -19,7 +22,7 @@ module GitFame
|
|
19
22
|
args.keys.each do |name|
|
20
23
|
instance_variable_set "@" + name.to_s, args[name]
|
21
24
|
end
|
22
|
-
convert_exclude_paths_to_array
|
25
|
+
@exclude = convert_exclude_paths_to_array
|
23
26
|
end
|
24
27
|
|
25
28
|
#
|
@@ -33,7 +36,10 @@ module GitFame
|
|
33
36
|
puts "Total number of commits: #{number_with_delimiter(commits)}\n"
|
34
37
|
|
35
38
|
fields = [:name, :loc, :commits, :files, :distribution]
|
36
|
-
|
39
|
+
if @bytype
|
40
|
+
fields << populate.instance_variable_get("@file_extensions").
|
41
|
+
uniq.sort
|
42
|
+
end
|
37
43
|
table(authors, fields: fields.flatten)
|
38
44
|
end
|
39
45
|
|
@@ -62,7 +68,8 @@ module GitFame
|
|
62
68
|
# @return Fixnum Total number of lines
|
63
69
|
#
|
64
70
|
def loc
|
65
|
-
populate.authors.
|
71
|
+
populate.authors.
|
72
|
+
inject(0){ |result, author| author.raw_loc + result }
|
66
73
|
end
|
67
74
|
|
68
75
|
#
|
@@ -70,13 +77,17 @@ module GitFame
|
|
70
77
|
#
|
71
78
|
def authors
|
72
79
|
authors = populate.instance_variable_get("@authors").values
|
73
|
-
@sort
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
80
|
+
if @sort
|
81
|
+
authors.sort_by do |author|
|
82
|
+
if @sort == "name"
|
83
|
+
author.send(@sort)
|
84
|
+
else
|
85
|
+
-1 * author.send("raw_#{@sort}")
|
86
|
+
end
|
78
87
|
end
|
79
|
-
|
88
|
+
else
|
89
|
+
authors
|
90
|
+
end
|
80
91
|
end
|
81
92
|
|
82
93
|
#
|
@@ -93,7 +104,7 @@ module GitFame
|
|
93
104
|
#
|
94
105
|
def execute(command)
|
95
106
|
Dir.chdir(@repository) do
|
96
|
-
return `#{command}
|
107
|
+
return `#{command}`.scrub
|
97
108
|
end
|
98
109
|
end
|
99
110
|
|
@@ -122,27 +133,44 @@ module GitFame
|
|
122
133
|
# @return GitFame
|
123
134
|
#
|
124
135
|
def populate
|
125
|
-
@
|
136
|
+
@_populate ||= begin
|
126
137
|
@files = execute("git ls-files").split("\n")
|
127
138
|
@file_extensions = []
|
128
139
|
remove_excluded_files
|
129
|
-
progressbar = SilentProgressbar.new(
|
140
|
+
progressbar = SilentProgressbar.new(
|
141
|
+
"Blame",
|
142
|
+
@files.count,
|
143
|
+
@progressbar
|
144
|
+
)
|
130
145
|
blame_opts = @whitespace ? "-w" : ""
|
131
146
|
@files.each do |file|
|
132
147
|
progressbar.inc
|
133
148
|
if @bytype
|
134
|
-
file_extension = File.extname(file).
|
149
|
+
file_extension = File.extname(file).gsub(/^\./, "")
|
135
150
|
file_extension = "unknown" if file_extension.empty?
|
136
151
|
end
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
152
|
+
|
153
|
+
unless type = Mimer.identify(File.join(@repository, file))
|
154
|
+
next
|
155
|
+
end
|
156
|
+
|
157
|
+
if type.binary?
|
158
|
+
next
|
159
|
+
end
|
160
|
+
|
161
|
+
# only count extensions that aren't binary
|
162
|
+
@file_extensions << file_extension
|
163
|
+
|
164
|
+
output = execute(
|
165
|
+
"git blame '#{file}' #{blame_opts} --line-porcelain"
|
166
|
+
)
|
167
|
+
output.scan(/^author (.+)$/).each do |author|
|
168
|
+
fetch(author.first).raw_loc += 1
|
169
|
+
@file_authors[author.first][file] ||= 1
|
170
|
+
if @bytype
|
171
|
+
fetch(author.first).
|
172
|
+
file_type_counts[file_extension] += 1
|
173
|
+
end
|
146
174
|
end
|
147
175
|
end
|
148
176
|
|
@@ -169,7 +197,7 @@ module GitFame
|
|
169
197
|
|
170
198
|
progressbar.finish
|
171
199
|
|
172
|
-
|
200
|
+
end
|
173
201
|
return self
|
174
202
|
end
|
175
203
|
|
@@ -177,7 +205,7 @@ module GitFame
|
|
177
205
|
# Converts @exclude argument to an array and removes leading slash
|
178
206
|
#
|
179
207
|
def convert_exclude_paths_to_array
|
180
|
-
@exclude
|
208
|
+
@exclude.split(",").map{|path| path.strip.sub(/\A\//, "") }
|
181
209
|
end
|
182
210
|
|
183
211
|
#
|
@@ -190,6 +218,5 @@ module GitFame
|
|
190
218
|
path
|
191
219
|
end.compact
|
192
220
|
end
|
193
|
-
|
194
221
|
end
|
195
222
|
end
|
data/lib/git_fame/version.rb
CHANGED
data/spec/git_fame_spec.rb
CHANGED
@@ -60,23 +60,42 @@ describe GitFame::Base do
|
|
60
60
|
|
61
61
|
describe "sort" do
|
62
62
|
it "should be able to sort #authors by name" do
|
63
|
-
authors = GitFame::Base.new({
|
64
|
-
|
63
|
+
authors = GitFame::Base.new({
|
64
|
+
repository: @repository,
|
65
|
+
sort: "name"
|
66
|
+
}).authors
|
67
|
+
authors.map(&:name).
|
68
|
+
should eq(["7rans", "Linus Oleander", "Magnus Holm"])
|
65
69
|
end
|
66
70
|
|
67
71
|
it "should be able to sort #authors by commits" do
|
68
|
-
authors = GitFame::Base.new({
|
69
|
-
|
72
|
+
authors = GitFame::Base.new({
|
73
|
+
repository: @repository,
|
74
|
+
sort: "commits"
|
75
|
+
}).authors
|
76
|
+
authors.map(&:name).
|
77
|
+
should eq(["Magnus Holm", "Linus Oleander", "7rans"])
|
70
78
|
end
|
71
79
|
|
72
80
|
it "should be able to sort #authors by files" do
|
73
|
-
authors = GitFame::Base.new({
|
74
|
-
|
81
|
+
authors = GitFame::Base.new({
|
82
|
+
repository: @repository,
|
83
|
+
sort: "files"
|
84
|
+
}).authors
|
85
|
+
authors.map(&:name).
|
86
|
+
should eq(["7rans", "Linus Oleander", "Magnus Holm"])
|
75
87
|
end
|
76
88
|
end
|
77
89
|
|
78
90
|
describe "#command_line_arguments" do
|
79
|
-
let(:subject)
|
91
|
+
let(:subject) do
|
92
|
+
GitFame::Base.new({
|
93
|
+
repository: @repository,
|
94
|
+
exclude: "lib",
|
95
|
+
bytype: true
|
96
|
+
})
|
97
|
+
end
|
98
|
+
|
80
99
|
it "should exclude the lib folder" do
|
81
100
|
subject.file_list.include?("lib/gash.rb").should be_false
|
82
101
|
end
|
@@ -105,7 +124,8 @@ describe GitFame::Base do
|
|
105
124
|
end
|
106
125
|
|
107
126
|
it "should know if a folder exists or not [absolute path]" do
|
108
|
-
GitFame::Base.git_repository?("/f67c2bcbfcfa30fccb36f72dca22a817").
|
127
|
+
GitFame::Base.git_repository?("/f67c2bcbfcfa30fccb36f72dca22a817").
|
128
|
+
should be_false
|
109
129
|
end
|
110
130
|
|
111
131
|
it "should know if a folder is a git repository [relative path]" do
|
@@ -113,7 +133,8 @@ describe GitFame::Base do
|
|
113
133
|
end
|
114
134
|
|
115
135
|
it "should know if a folder exists or not [relative path]" do
|
116
|
-
GitFame::Base.git_repository?("f67c2bcbfcfa30fccb36f72dca22a817").
|
136
|
+
GitFame::Base.git_repository?("f67c2bcbfcfa30fccb36f72dca22a817").
|
137
|
+
should be_false
|
117
138
|
end
|
118
139
|
end
|
119
140
|
end
|
metadata
CHANGED
@@ -1,83 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_fame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: progressbar
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: trollop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: hirb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mimer_plus
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: string-scrub
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- -
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
description: Generates some awesome stats from git-blame
|
@@ -88,9 +116,9 @@ executables:
|
|
88
116
|
extensions: []
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
91
|
-
- .gitignore
|
92
|
-
- .gitmodules
|
93
|
-
- .rspec
|
119
|
+
- ".gitignore"
|
120
|
+
- ".gitmodules"
|
121
|
+
- ".rspec"
|
94
122
|
- Gemfile
|
95
123
|
- LICENSE
|
96
124
|
- README.md
|
@@ -114,17 +142,17 @@ require_paths:
|
|
114
142
|
- lib
|
115
143
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
144
|
requirements:
|
117
|
-
- -
|
145
|
+
- - ">="
|
118
146
|
- !ruby/object:Gem::Version
|
119
147
|
version: 1.9.2
|
120
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
149
|
requirements:
|
122
|
-
- -
|
150
|
+
- - ">="
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '0'
|
125
153
|
requirements: []
|
126
154
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.5
|
128
156
|
signing_key:
|
129
157
|
specification_version: 4
|
130
158
|
summary: 'Generates some awesome stats from git-blame A Ruby wrapper for git-blame.
|