git_fame 1.5.0 → 1.6.0
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/.travis.yml +1 -0
- data/README.md +3 -3
- data/bin/git-fame +3 -1
- data/git_fame.gemspec +8 -4
- data/lib/git_fame/base.rb +47 -18
- data/lib/git_fame/version.rb +1 -1
- data/spec/git_fame_spec.rb +20 -15
- metadata +24 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b26bdf2f4da7bdd079f978625dd588c62129595
|
4
|
+
data.tar.gz: f0f316759efda81f61fdee295afe76e1cac9dc7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e646b20e3fca5711245540a3c2d1996adbfbeeeed14e59ff9c1a26324d5cbbf5b8c303c87fb8b9aed287884d19be85d9ab2d67379d1a2992fd7046e77096b9a2
|
7
|
+
data.tar.gz: 4105beaa8b3e8d0000a6dbe00ce6a434012345e1f204f579344ce80c58a2dbf6cd744856e95b46eca4c17057457e6dfee7e577f5c0ae5089879f257e8854b564
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,7 @@ Run `git fame` to generate output as above.
|
|
49
49
|
|
50
50
|
- `git fame --bytype` Should a breakout of line counts by file type be output? Default is `false`.
|
51
51
|
- `git fame --exclude=paths/to/files,paths/to/other/files` Comma separated, realtive paths to exclude from the counts. Note that you should not start the paths with a dot. Default is none.
|
52
|
-
- `git fame --
|
52
|
+
- `git fame --sort=loc` Order table by `loc`. Available options are: `loc`, `commits` and `files`. Default is `loc`.
|
53
53
|
- `git fame --progressbar=1` Should a progressbar be visible during the calculation? Default is `1`.
|
54
54
|
- `git fame --whitespace` Ignore whitespace changes when blaming files. Default is `false`.
|
55
55
|
- `git fame --repository=/path/to/repo` Git repository to be used. Default is the current folder.
|
@@ -90,7 +90,7 @@ repository = GitFame::Base.new({
|
|
90
90
|
|
91
91
|
#### Print csv table to console
|
92
92
|
|
93
|
-
`repository.csv_puts
|
93
|
+
`repository.csv_puts`
|
94
94
|
|
95
95
|
### Statistics
|
96
96
|
|
@@ -139,4 +139,4 @@ The list of authors may include duplicate people. If a git user's configured nam
|
|
139
139
|
|
140
140
|
## License
|
141
141
|
|
142
|
-
*GitFame* is released under the *MIT license*.
|
142
|
+
*GitFame* is released under the *MIT license*.
|
data/bin/git-fame
CHANGED
@@ -5,7 +5,7 @@ require "trollop"
|
|
5
5
|
|
6
6
|
sort = ["name", "commits", "loc", "files"]
|
7
7
|
opts = Trollop::options do
|
8
|
-
version "git-fame #{GitFame::VERSION} (c)
|
8
|
+
version "git-fame #{GitFame::VERSION} (c) 2012-#{Date.today.year} Linus Oleander"
|
9
9
|
opt :repository, "What git repository should be used?", default: "."
|
10
10
|
opt :sort, "What should the printed table be sorted by? #{sort.join(", ")}", default: "loc", type: String
|
11
11
|
opt :progressbar, "Show progressbar during calculation", default: 1, type: Integer
|
@@ -13,6 +13,7 @@ opts = Trollop::options do
|
|
13
13
|
opt :bytype, "Group line counts by file extension (i.e. .rb, .erb, .yml)", default: false
|
14
14
|
opt :include, "Paths to include in git ls-files", default: "", type: String
|
15
15
|
opt :exclude, "Paths to exclude (comma separated)", default: "", type: String
|
16
|
+
opt :extension, "Comma-separated list of extensions to consider, leave blank for all", default: "", type: String
|
16
17
|
opt :branch, "Branch to run on", default: "master", type: String
|
17
18
|
opt :format, "Format (pretty/csv)", default: "pretty", type: String
|
18
19
|
end
|
@@ -27,6 +28,7 @@ fame = GitFame::Base.new({
|
|
27
28
|
bytype: opts[:bytype],
|
28
29
|
include: opts[:include],
|
29
30
|
exclude: opts[:exclude],
|
31
|
+
extensions: opts[:extension],
|
30
32
|
branch: opts[:branch]
|
31
33
|
})
|
32
34
|
opts[:format] == "csv" ? fame.csv_puts : fame.pretty_puts
|
data/git_fame.gemspec
CHANGED
@@ -4,9 +4,9 @@ require File.expand_path('../lib/git_fame/version', __FILE__)
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.authors = ["Linus Oleander"]
|
6
6
|
gem.email = ["linus@oleander.nu"]
|
7
|
-
gem.description = %q{Generates
|
7
|
+
gem.description = %q{Generates awesome stats from git-blame}
|
8
8
|
gem.summary = %q{
|
9
|
-
Generates
|
9
|
+
Generates awesome stats from git-blame
|
10
10
|
|
11
11
|
A Ruby wrapper for git-blame.
|
12
12
|
Generates data like:
|
@@ -14,7 +14,7 @@ Generates data like:
|
|
14
14
|
- Number of commits by user
|
15
15
|
- Lines of code by a user
|
16
16
|
}
|
17
|
-
|
17
|
+
|
18
18
|
gem.homepage = "https://github.com/oleander/git-fame-rb"
|
19
19
|
|
20
20
|
gem.files = `git ls-files`.split($\)
|
@@ -28,10 +28,14 @@ Generates data like:
|
|
28
28
|
gem.add_dependency("trollop")
|
29
29
|
gem.add_dependency("hirb")
|
30
30
|
gem.add_dependency("mimer_plus")
|
31
|
-
|
31
|
+
|
32
|
+
if RUBY_VERSION.to_f < 2.1
|
33
|
+
gem.add_dependency("scrub_rb")
|
34
|
+
end
|
32
35
|
|
33
36
|
gem.add_development_dependency("rspec", "2.10.0")
|
34
37
|
gem.add_development_dependency("rake")
|
35
38
|
gem.add_development_dependency("coveralls")
|
39
|
+
|
36
40
|
gem.required_ruby_version = ">= 1.9.2"
|
37
41
|
end
|
data/lib/git_fame/base.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require "string-scrub"
|
2
1
|
require "csv"
|
3
2
|
require_relative "./errors"
|
3
|
+
if RUBY_VERSION.to_f < 2.1
|
4
|
+
require "scrub_rb"
|
5
|
+
end
|
4
6
|
|
5
7
|
module GitFame
|
6
8
|
class Base
|
@@ -19,6 +21,7 @@ module GitFame
|
|
19
21
|
@progressbar = false
|
20
22
|
@whitespace = false
|
21
23
|
@bytype = false
|
24
|
+
@extensions = ""
|
22
25
|
@exclude = ""
|
23
26
|
@include = ""
|
24
27
|
@authors = {}
|
@@ -27,7 +30,19 @@ module GitFame
|
|
27
30
|
instance_variable_set "@" + name.to_s, args[name]
|
28
31
|
end
|
29
32
|
@exclude = convert_exclude_paths_to_array
|
33
|
+
@extensions = convert_extensions_to_array
|
30
34
|
@branch = (@branch.nil? or @branch.empty?) ? "master" : @branch
|
35
|
+
|
36
|
+
# Fields that should be visible in the final table
|
37
|
+
# Used by #csv_puts, #to_csv and #pretty_puts
|
38
|
+
# Format: [ [:method_on_author, "custom column name"] ]
|
39
|
+
@visible_fields = [
|
40
|
+
:name,
|
41
|
+
:loc,
|
42
|
+
:commits,
|
43
|
+
:files,
|
44
|
+
[:distribution, "distribution (%)"]
|
45
|
+
]
|
31
46
|
end
|
32
47
|
|
33
48
|
#
|
@@ -66,7 +81,7 @@ module GitFame
|
|
66
81
|
#
|
67
82
|
def to_csv
|
68
83
|
CSV.generate do |csv|
|
69
|
-
csv <<
|
84
|
+
csv << printable_fields
|
70
85
|
authors.each do |author|
|
71
86
|
csv << fields.map do |f|
|
72
87
|
author.send(f)
|
@@ -75,19 +90,6 @@ module GitFame
|
|
75
90
|
end
|
76
91
|
end
|
77
92
|
|
78
|
-
#
|
79
|
-
# Calculate columns to show
|
80
|
-
#
|
81
|
-
def fields
|
82
|
-
@_fields ||= begin
|
83
|
-
fields = [:name, :loc, :commits, :files, :distribution]
|
84
|
-
if @bytype
|
85
|
-
fields += populate.instance_variable_get("@file_extensions")
|
86
|
-
end
|
87
|
-
fields.uniq
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
93
|
#
|
92
94
|
# @return Fixnum Total number of files
|
93
95
|
#
|
@@ -148,6 +150,25 @@ module GitFame
|
|
148
150
|
|
149
151
|
private
|
150
152
|
|
153
|
+
def printable_fields
|
154
|
+
@_printable_fields ||= raw_fields.map do |field|
|
155
|
+
field.is_a?(Array) ? field.last : field
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def raw_fields
|
160
|
+
return @visible_fields unless @bytype
|
161
|
+
@_raw_fields ||= (
|
162
|
+
@visible_fields + populate.instance_variable_get("@file_extensions")
|
163
|
+
).uniq
|
164
|
+
end
|
165
|
+
|
166
|
+
def fields
|
167
|
+
@_fields ||= raw_fields.map do |field|
|
168
|
+
field.is_a?(Array) ? field.first : field
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
151
172
|
#
|
152
173
|
# @command String Command to be executed inside the @repository path
|
153
174
|
#
|
@@ -185,8 +206,9 @@ module GitFame
|
|
185
206
|
raise BranchNotFound.new("Does '#{@branch}' exist?")
|
186
207
|
end
|
187
208
|
|
188
|
-
|
189
|
-
|
209
|
+
command = "git ls-tree -r #{@branch} --name-only #{@include}"
|
210
|
+
command += " | grep \"\\.\\(#{@extensions.join("\\|")}\\)$\"" unless @extensions.empty?
|
211
|
+
@files = execute(command).split("\n")
|
190
212
|
@file_extensions = []
|
191
213
|
remove_excluded_files
|
192
214
|
progressbar = SilentProgressbar.new(
|
@@ -260,13 +282,20 @@ module GitFame
|
|
260
282
|
@exclude.split(",").map{|path| path.strip.sub(/\A\//, "") }
|
261
283
|
end
|
262
284
|
|
285
|
+
#
|
286
|
+
# Converts @extensions argument to an array
|
287
|
+
#
|
288
|
+
def convert_extensions_to_array
|
289
|
+
@extensions.split(",")
|
290
|
+
end
|
291
|
+
|
263
292
|
#
|
264
293
|
# Removes files matching paths in @exclude from @files instance variable
|
265
294
|
#
|
266
295
|
def remove_excluded_files
|
267
296
|
return if @exclude.empty?
|
268
297
|
@files = @files.map do |path|
|
269
|
-
next if
|
298
|
+
next if path =~ /\A(#{@exclude.join("|")})/
|
270
299
|
path
|
271
300
|
end.compact
|
272
301
|
end
|
data/lib/git_fame/version.rb
CHANGED
data/spec/git_fame_spec.rb
CHANGED
@@ -28,10 +28,10 @@ describe GitFame::Base do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
describe "format" do
|
31
|
-
let(:author) do
|
31
|
+
let(:author) do
|
32
32
|
GitFame::Author.new({
|
33
|
-
raw_commits: 12345,
|
34
|
-
raw_files: 6789,
|
33
|
+
raw_commits: 12345,
|
34
|
+
raw_files: 6789,
|
35
35
|
raw_loc: 1234
|
36
36
|
})
|
37
37
|
end
|
@@ -61,7 +61,7 @@ describe GitFame::Base do
|
|
61
61
|
describe "sort" do
|
62
62
|
it "should be able to sort #authors by name" do
|
63
63
|
authors = GitFame::Base.new({
|
64
|
-
repository: @repository,
|
64
|
+
repository: @repository,
|
65
65
|
sort: "name"
|
66
66
|
}).authors
|
67
67
|
authors.map(&:name).
|
@@ -70,7 +70,7 @@ describe GitFame::Base do
|
|
70
70
|
|
71
71
|
it "should be able to sort #authors by commits" do
|
72
72
|
authors = GitFame::Base.new({
|
73
|
-
repository: @repository,
|
73
|
+
repository: @repository,
|
74
74
|
sort: "commits"
|
75
75
|
}).authors
|
76
76
|
authors.map(&:name).
|
@@ -79,7 +79,7 @@ describe GitFame::Base do
|
|
79
79
|
|
80
80
|
it "should be able to sort #authors by files" do
|
81
81
|
authors = GitFame::Base.new({
|
82
|
-
repository: @repository,
|
82
|
+
repository: @repository,
|
83
83
|
sort: "files"
|
84
84
|
}).authors
|
85
85
|
authors.map(&:name).
|
@@ -88,19 +88,24 @@ describe GitFame::Base do
|
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "#command_line_arguments" do
|
91
|
-
let(:subject) do
|
91
|
+
let(:subject) do
|
92
92
|
GitFame::Base.new({
|
93
|
-
repository: @repository,
|
94
|
-
exclude: "lib",
|
95
|
-
bytype: true
|
96
|
-
|
93
|
+
repository: @repository,
|
94
|
+
exclude: "lib",
|
95
|
+
bytype: true,
|
96
|
+
extensions: "rb,rdoc"
|
97
|
+
})
|
97
98
|
end
|
98
99
|
|
99
100
|
it "should exclude the lib folder" do
|
100
101
|
subject.file_list.include?("lib/gash.rb").should be_false
|
101
102
|
end
|
102
103
|
|
103
|
-
|
104
|
+
it "should exclude non rb or rdoc files" do
|
105
|
+
subject.file_list.include?("HISTORY").should be_false
|
106
|
+
end
|
107
|
+
|
108
|
+
let(:author) { subject.authors.find { |author| author.name == "7rans" } }
|
104
109
|
it "should break out counts by file type" do
|
105
110
|
author.file_type_counts["rdoc"].should eq(23)
|
106
111
|
end
|
@@ -126,7 +131,7 @@ describe GitFame::Base do
|
|
126
131
|
end
|
127
132
|
|
128
133
|
it "should be equal to" do
|
129
|
-
subject.to_csv.should eq("name,loc,commits,files,distribution\n" \
|
134
|
+
subject.to_csv.should eq("name,loc,commits,files,distribution (%)\n" \
|
130
135
|
"Magnus Holm,586,41,4,54.2 / 58.6 / 25.0\n" \
|
131
136
|
"7rans,360,6,10,33.3 / 8.6 / 62.5\n" \
|
132
137
|
"Linus Oleander,136,23,7,12.6 / 32.9 / 43.8\n")
|
@@ -156,7 +161,7 @@ describe GitFame::Base do
|
|
156
161
|
describe "branches" do
|
157
162
|
it "should handle existing branches" do
|
158
163
|
authors = GitFame::Base.new({
|
159
|
-
repository: @repository,
|
164
|
+
repository: @repository,
|
160
165
|
branch: "0.1.0"
|
161
166
|
}).authors
|
162
167
|
|
@@ -167,7 +172,7 @@ describe GitFame::Base do
|
|
167
172
|
it "should raise an error if branch doesn't exist" do
|
168
173
|
expect {
|
169
174
|
GitFame::Base.new({
|
170
|
-
repository: @repository,
|
175
|
+
repository: @repository,
|
171
176
|
branch: "f67c2bcbfcfa30fccb36f72dca22a817"
|
172
177
|
}).authors
|
173
178
|
}.to raise_error(GitFame::BranchNotFound)
|
metadata
CHANGED
@@ -1,83 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_fame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.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: 2016-05-16 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
|
-
- -
|
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
|
-
- - '>='
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
@@ -98,31 +84,31 @@ dependencies:
|
|
98
84
|
name: rake
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
89
|
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- -
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
98
|
name: coveralls
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - ">="
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: '0'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
|
-
- -
|
108
|
+
- - ">="
|
123
109
|
- !ruby/object:Gem::Version
|
124
110
|
version: '0'
|
125
|
-
description: Generates
|
111
|
+
description: Generates awesome stats from git-blame
|
126
112
|
email:
|
127
113
|
- linus@oleander.nu
|
128
114
|
executables:
|
@@ -130,10 +116,10 @@ executables:
|
|
130
116
|
extensions: []
|
131
117
|
extra_rdoc_files: []
|
132
118
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .gitmodules
|
135
|
-
- .rspec
|
136
|
-
- .travis.yml
|
119
|
+
- ".gitignore"
|
120
|
+
- ".gitmodules"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
137
123
|
- Gemfile
|
138
124
|
- LICENSE
|
139
125
|
- README.md
|
@@ -158,12 +144,12 @@ require_paths:
|
|
158
144
|
- lib
|
159
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
146
|
requirements:
|
161
|
-
- -
|
147
|
+
- - ">="
|
162
148
|
- !ruby/object:Gem::Version
|
163
149
|
version: 1.9.2
|
164
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
151
|
requirements:
|
166
|
-
- -
|
152
|
+
- - ">="
|
167
153
|
- !ruby/object:Gem::Version
|
168
154
|
version: '0'
|
169
155
|
requirements: []
|
@@ -171,9 +157,9 @@ rubyforge_project:
|
|
171
157
|
rubygems_version: 2.4.8
|
172
158
|
signing_key:
|
173
159
|
specification_version: 4
|
174
|
-
summary: 'Generates
|
175
|
-
|
176
|
-
|
160
|
+
summary: 'Generates awesome stats from git-blame A Ruby wrapper for git-blame. Generates
|
161
|
+
data like: - Number of files changed by a user - Number of commits by user - Lines
|
162
|
+
of code by a user'
|
177
163
|
test_files:
|
178
164
|
- spec/git_fame_spec.rb
|
179
165
|
- spec/spec_helper.rb
|