git_fame 1.3.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +13 -0
- data/README.md +11 -5
- data/bin/git-fame +5 -1
- data/git_fame.gemspec +3 -2
- data/lib/git_fame/base.rb +31 -8
- data/lib/git_fame/errors.rb +4 -0
- data/lib/git_fame/version.rb +1 -1
- data/spec/git_fame_spec.rb +26 -5
- data/spec/spec_helper.rb +3 -0
- metadata +39 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36524eed33e537c38d7e4d6e676e1450d4c4df54
|
4
|
+
data.tar.gz: 40de0dbd6449bda36a1e5ae2a007cf9634a40d24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 974e123f9581f634674bde0079ae60e58a3dd0235a871af48a729cf87300211d8083465b83ddce133a928aaea6764ce23bd68887bd7c92f881d8441661d62e97
|
7
|
+
data.tar.gz: 20e4ed931d1a244afe97697c40231fdd20b2ca77afefa437a4fce80e1ab9662bca058da8a987f20fb65d992fff69e2196a24275349a80c10cfdc879a8108d320
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.0
|
4
|
+
- 1.9.3
|
5
|
+
script:
|
6
|
+
- 'rspec spec/git_fame_spec.rb --format documentation'
|
7
|
+
notifications:
|
8
|
+
webhooks:
|
9
|
+
urls:
|
10
|
+
- https://webhooks.gitter.im/e/e2b034ea2dbc919b02f7
|
11
|
+
on_success: change # options: [always|never|change] default: always
|
12
|
+
on_failure: change # options: [always|never|change] default: always
|
13
|
+
on_start: false # default: false
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# GitFame
|
2
|
+
[![Join the chat at https://gitter.im/oleander/git-fame-rb](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/oleander/git-fame-rb)
|
3
|
+
[![Build Status](https://travis-ci.org/oleander/git-fame-rb.svg?branch=master)](https://travis-ci.org/oleander/git-fame-rb)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/oleander/git-fame-rb/badge.svg?branch=master&service=github)](https://coveralls.io/github/oleander/git-fame-rb?branch=master)
|
2
5
|
|
3
6
|
Pretty-print collaborators sorted by contributions.
|
4
7
|
|
@@ -44,12 +47,13 @@ Run `git fame` to generate output as above.
|
|
44
47
|
|
45
48
|
#### Options
|
46
49
|
|
47
|
-
- `git fame --bytype` Should a breakout of line counts by file type be output? Default is
|
48
|
-
- `git fame --exclude=paths/to/files,paths/to/other/files` Comma separated paths to exclude from the counts. Default is none.
|
50
|
+
- `git fame --bytype` Should a breakout of line counts by file type be output? Default is `false`.
|
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.
|
49
52
|
- `git fame --order=loc` Order table by `loc`. Available options are: `loc`, `commits` and `files`. Default is `loc`.
|
50
53
|
- `git fame --progressbar=1` Should a progressbar be visible during the calculation? Default is `1`.
|
51
54
|
- `git fame --whitespace` Ignore whitespace changes when blaming files. Default is `false`.
|
52
55
|
- `git fame --repository=/path/to/repo` Git repository to be used. Default is the current folder.
|
56
|
+
- `git fame --branch=master` Branch to run on. Default is `master`.
|
53
57
|
|
54
58
|
### Class
|
55
59
|
|
@@ -63,6 +67,7 @@ Want to work with the data before printing it?
|
|
63
67
|
- **whitespace** (Boolean) Ignore whitespace changes when blaming files. Default is `false`.
|
64
68
|
- **bytype** (Boolean) Should a breakout of line counts by file type be output? Default is 'false'
|
65
69
|
- **exclude** (String) Comma separated paths to exclude from the counts. Default is none.
|
70
|
+
- **branch** (String) Branch to run on. Default is `master`.
|
66
71
|
|
67
72
|
``` ruby
|
68
73
|
repository = GitFame::Base.new({
|
@@ -71,7 +76,8 @@ repository = GitFame::Base.new({
|
|
71
76
|
progressbar: false,
|
72
77
|
whitespace: false
|
73
78
|
bytype: false,
|
74
|
-
exclude: "vendor, public/assets"
|
79
|
+
exclude: "vendor, public/assets",
|
80
|
+
branch: "master"
|
75
81
|
})
|
76
82
|
```
|
77
83
|
|
@@ -105,7 +111,7 @@ repository = GitFame::Base.new({
|
|
105
111
|
|
106
112
|
#### A note about authors found
|
107
113
|
|
108
|
-
The list of authors may include
|
114
|
+
The list of authors may include duplicate people. If a git user's configured name or email address change over time, the person will appear multiple times in this list (and your repo's git history). Git allows you to configure this using the .mailmap feature. See ````git shortlog --help```` for more information.
|
109
115
|
|
110
116
|
## Contributing
|
111
117
|
|
@@ -118,7 +124,7 @@ The list of authors may include what you perceive to be duplicate people. If a g
|
|
118
124
|
## Testing
|
119
125
|
|
120
126
|
1. Download fixtures (`spec/fixtures`) using `git submodule update --init`.
|
121
|
-
2. Run rspec using `rspec spec`.
|
127
|
+
2. Run rspec using `rspec spec/git_fame_spec.rb`.
|
122
128
|
|
123
129
|
## Requirements
|
124
130
|
|
data/bin/git-fame
CHANGED
@@ -11,7 +11,9 @@ opts = Trollop::options do
|
|
11
11
|
opt :progressbar, "Show progressbar during calculation", default: 1, type: Integer
|
12
12
|
opt :whitespace, "Ignore whitespace changes", default: false
|
13
13
|
opt :bytype, "Group line counts by file extension (i.e. .rb, .erb, .yml)", default: false
|
14
|
+
opt :include, "Paths to include in git ls-files", default: "", type: String
|
14
15
|
opt :exclude, "Paths to exclude (comma separated)", default: "", type: String
|
16
|
+
opt :branch, "Branch to run on", default: "master", type: String
|
15
17
|
end
|
16
18
|
|
17
19
|
Trollop::die :repository, "is not a git repository" unless GitFame::Base.git_repository?(opts[:repository])
|
@@ -22,5 +24,7 @@ GitFame::Base.new({
|
|
22
24
|
sort: opts[:sort],
|
23
25
|
whitespace: opts[:whitespace],
|
24
26
|
bytype: opts[:bytype],
|
25
|
-
|
27
|
+
include: opts[:include],
|
28
|
+
exclude: opts[:exclude],
|
29
|
+
branch: opts[:branch]
|
26
30
|
}).pretty_puts
|
data/git_fame.gemspec
CHANGED
@@ -29,8 +29,9 @@ Generates data like:
|
|
29
29
|
gem.add_dependency("hirb")
|
30
30
|
gem.add_dependency("mimer_plus")
|
31
31
|
gem.add_dependency("string-scrub")
|
32
|
-
|
33
|
-
gem.add_development_dependency("rspec")
|
32
|
+
|
33
|
+
gem.add_development_dependency("rspec", "2.10.0")
|
34
34
|
gem.add_development_dependency("rake")
|
35
|
+
gem.add_development_dependency("coveralls")
|
35
36
|
gem.required_ruby_version = ">= 1.9.2"
|
36
37
|
end
|
data/lib/git_fame/base.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "string-scrub"
|
2
|
+
require_relative "./errors"
|
2
3
|
|
3
4
|
module GitFame
|
4
5
|
class Base
|
@@ -8,8 +9,9 @@ module GitFame
|
|
8
9
|
# @args[:repository] String Absolute path to git repository
|
9
10
|
# @args[:sort] String What should #authors be sorted by?
|
10
11
|
# @args[:bytype] Boolean Should counts be grouped by file extension?
|
11
|
-
# @args[:exclude] String Comma-separated list of paths in the repo
|
12
|
+
# @args[:exclude] String Comma-separated list of paths in the repo
|
12
13
|
# which should be excluded
|
14
|
+
# @args[:branch] String Branch to run from
|
13
15
|
#
|
14
16
|
def initialize(args)
|
15
17
|
@sort = "loc"
|
@@ -17,12 +19,14 @@ module GitFame
|
|
17
19
|
@whitespace = false
|
18
20
|
@bytype = false
|
19
21
|
@exclude = ""
|
22
|
+
@include = ""
|
20
23
|
@authors = {}
|
21
24
|
@file_authors = Hash.new { |h,k| h[k] = {} }
|
22
|
-
args.keys.each do |name|
|
25
|
+
args.keys.each do |name|
|
23
26
|
instance_variable_set "@" + name.to_s, args[name]
|
24
27
|
end
|
25
28
|
@exclude = convert_exclude_paths_to_array
|
29
|
+
@branch = (@branch.nil? or @branch.empty?) ? "master" : @branch
|
26
30
|
end
|
27
31
|
|
28
32
|
#
|
@@ -95,10 +99,23 @@ module GitFame
|
|
95
99
|
# @dir Path (relative or absolute) to git repository
|
96
100
|
#
|
97
101
|
def self.git_repository?(dir)
|
98
|
-
|
102
|
+
return false unless File.directory?(dir)
|
103
|
+
Dir.chdir(dir) do
|
104
|
+
system "git rev-parse --git-dir > /dev/null 2>&1"
|
105
|
+
end
|
99
106
|
end
|
100
107
|
|
101
108
|
private
|
109
|
+
|
110
|
+
#
|
111
|
+
# @return Boolean Does the branch exist?
|
112
|
+
#
|
113
|
+
def branch_exists?
|
114
|
+
Dir.chdir(@repository) do
|
115
|
+
system "git show-ref #{@branch} > /dev/null 2>&1"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
102
119
|
#
|
103
120
|
# @command String Command to be executed inside the @repository path
|
104
121
|
#
|
@@ -134,12 +151,17 @@ module GitFame
|
|
134
151
|
#
|
135
152
|
def populate
|
136
153
|
@_populate ||= begin
|
137
|
-
|
154
|
+
unless branch_exists?
|
155
|
+
raise BranchNotFound.new("Does '#{@branch}' exist?")
|
156
|
+
end
|
157
|
+
|
158
|
+
@files = execute("git ls-tree -r #{@branch} --name-only #{@include}").
|
159
|
+
split("\n")
|
138
160
|
@file_extensions = []
|
139
161
|
remove_excluded_files
|
140
162
|
progressbar = SilentProgressbar.new(
|
141
|
-
"Blame",
|
142
|
-
@files.count,
|
163
|
+
"Blame",
|
164
|
+
@files.count,
|
143
165
|
@progressbar
|
144
166
|
)
|
145
167
|
blame_opts = @whitespace ? "-w" : ""
|
@@ -161,8 +183,9 @@ module GitFame
|
|
161
183
|
# only count extensions that aren't binary
|
162
184
|
@file_extensions << file_extension
|
163
185
|
|
186
|
+
|
164
187
|
output = execute(
|
165
|
-
"git blame
|
188
|
+
"git blame #{blame_opts} --line-porcelain #{@branch} -- '#{file}'"
|
166
189
|
)
|
167
190
|
output.scan(/^author (.+)$/).each do |author|
|
168
191
|
fetch(author.first).raw_loc += 1
|
@@ -174,7 +197,7 @@ module GitFame
|
|
174
197
|
end
|
175
198
|
end
|
176
199
|
|
177
|
-
execute("git shortlog -se").split("\n").map do |l|
|
200
|
+
execute("git shortlog #{@branch} -se").split("\n").map do |l|
|
178
201
|
_, commits, u = l.match(%r{^\s*(\d+)\s+(.+?)\s+<.+?>}).to_a
|
179
202
|
user = fetch(u)
|
180
203
|
# Has this user been updated before?
|
data/lib/git_fame/version.rb
CHANGED
data/spec/git_fame_spec.rb
CHANGED
@@ -2,7 +2,7 @@ describe GitFame::Base do
|
|
2
2
|
let(:subject) { GitFame::Base.new({repository: @repository}) }
|
3
3
|
describe "#authors" do
|
4
4
|
it "should have a list of authors" do
|
5
|
-
should have(3).authors
|
5
|
+
subject.should have(3).authors
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "author" do
|
@@ -120,21 +120,42 @@ describe GitFame::Base do
|
|
120
120
|
|
121
121
|
describe ".git_repository?" do
|
122
122
|
it "should know if a folder is a git repository [absolute path]" do
|
123
|
-
GitFame::Base.git_repository?(@repository).should
|
123
|
+
GitFame::Base.git_repository?(@repository).should eq(true)
|
124
124
|
end
|
125
125
|
|
126
126
|
it "should know if a folder exists or not [absolute path]" do
|
127
127
|
GitFame::Base.git_repository?("/f67c2bcbfcfa30fccb36f72dca22a817").
|
128
|
-
should
|
128
|
+
should eq(false)
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should know if a folder is a git repository [relative path]" do
|
132
|
-
GitFame::Base.git_repository?("spec/fixtures/gash").should
|
132
|
+
GitFame::Base.git_repository?("spec/fixtures/gash").should eq(true)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "should know if a folder exists or not [relative path]" do
|
136
136
|
GitFame::Base.git_repository?("f67c2bcbfcfa30fccb36f72dca22a817").
|
137
|
-
should
|
137
|
+
should eq(false)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "branches" do
|
142
|
+
it "should handle existing branches" do
|
143
|
+
authors = GitFame::Base.new({
|
144
|
+
repository: @repository,
|
145
|
+
branch: "0.1.0"
|
146
|
+
}).authors
|
147
|
+
|
148
|
+
authors.count.should eq(1)
|
149
|
+
authors.first.name.should eq("Magnus Holm")
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should raise an error if branch doesn't exist" do
|
153
|
+
expect {
|
154
|
+
GitFame::Base.new({
|
155
|
+
repository: @repository,
|
156
|
+
branch: "f67c2bcbfcfa30fccb36f72dca22a817"
|
157
|
+
}).authors
|
158
|
+
}.to raise_error(GitFame::BranchNotFound)
|
138
159
|
end
|
139
160
|
end
|
140
161
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,111 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_fame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-21 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
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: string-scrub
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.10.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.10.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '0'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- -
|
108
|
+
- - '>='
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: coveralls
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - '>='
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - '>='
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
description: Generates some awesome stats from git-blame
|
@@ -116,9 +130,10 @@ executables:
|
|
116
130
|
extensions: []
|
117
131
|
extra_rdoc_files: []
|
118
132
|
files:
|
119
|
-
-
|
120
|
-
-
|
121
|
-
-
|
133
|
+
- .gitignore
|
134
|
+
- .gitmodules
|
135
|
+
- .rspec
|
136
|
+
- .travis.yml
|
122
137
|
- Gemfile
|
123
138
|
- LICENSE
|
124
139
|
- README.md
|
@@ -128,6 +143,7 @@ files:
|
|
128
143
|
- lib/git_fame.rb
|
129
144
|
- lib/git_fame/author.rb
|
130
145
|
- lib/git_fame/base.rb
|
146
|
+
- lib/git_fame/errors.rb
|
131
147
|
- lib/git_fame/helper.rb
|
132
148
|
- lib/git_fame/silent_progressbar.rb
|
133
149
|
- lib/git_fame/version.rb
|
@@ -142,17 +158,17 @@ require_paths:
|
|
142
158
|
- lib
|
143
159
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
160
|
requirements:
|
145
|
-
- -
|
161
|
+
- - '>='
|
146
162
|
- !ruby/object:Gem::Version
|
147
163
|
version: 1.9.2
|
148
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
165
|
requirements:
|
150
|
-
- -
|
166
|
+
- - '>='
|
151
167
|
- !ruby/object:Gem::Version
|
152
168
|
version: '0'
|
153
169
|
requirements: []
|
154
170
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.4.
|
171
|
+
rubygems_version: 2.4.8
|
156
172
|
signing_key:
|
157
173
|
specification_version: 4
|
158
174
|
summary: 'Generates some awesome stats from git-blame A Ruby wrapper for git-blame.
|