git_fame 1.7.1 → 1.7.2
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 -1
- data/bin/git-fame +3 -1
- data/lib/git_fame/base.rb +11 -8
- data/lib/git_fame/version.rb +1 -1
- data/spec/bin_spec.rb +44 -0
- data/spec/git_fame_spec.rb +12 -0
- data/spec/spec_helper.rb +22 -1
- data/spec/support/startup.rb +14 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd0e84253d48334aadecae9770216086d4ac67e7
|
4
|
+
data.tar.gz: af9f1a996b0e68e4d537cfe456319d66f66c9c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da9a68656473b6c1bfaefad0bab00634b2ff0f5fafd8b999ebc695ead627e4b3340ff80a6ce5409ac122a81a5e99eae73c6d7ce337f910cf94b6c62ef9cf151b
|
7
|
+
data.tar.gz: 87fbb2d5a0f67140eb55929ef1e5ec1aedc7169c711337425873ee652579f52f1bda3f805dce5d1d419cd36f0a320a8cffd89eaf58a47864e72b584170034801
|
data/.travis.yml
CHANGED
data/bin/git-fame
CHANGED
data/lib/git_fame/base.rb
CHANGED
@@ -39,9 +39,13 @@ module GitFame
|
|
39
39
|
@bytype = args.fetch(:bytype, false)
|
40
40
|
@branch = args.fetch(:branch, default_branch)
|
41
41
|
|
42
|
-
#
|
43
|
-
if
|
44
|
-
|
42
|
+
# Figure out what branch the caller is using
|
43
|
+
if present?(@branch = args[:branch])
|
44
|
+
unless branch_exists?(@branch)
|
45
|
+
raise GitFame::BranchNotFound, "Branch '#{@branch}' does not exist"
|
46
|
+
end
|
47
|
+
else
|
48
|
+
@branch = default_branch
|
45
49
|
end
|
46
50
|
|
47
51
|
# Fields that should be visible in the final table
|
@@ -219,6 +223,10 @@ module GitFame
|
|
219
223
|
value.nil? or value.empty?
|
220
224
|
end
|
221
225
|
|
226
|
+
def present?(value)
|
227
|
+
not blank?(value)
|
228
|
+
end
|
229
|
+
|
222
230
|
# Includes fields from file extensions
|
223
231
|
def raw_fields
|
224
232
|
return @visible_fields unless @bytype
|
@@ -255,11 +263,6 @@ module GitFame
|
|
255
263
|
"Could not run '#{command}' => #{message}"
|
256
264
|
end
|
257
265
|
|
258
|
-
# Boolean Does the branch exist?
|
259
|
-
def default_branch_exists?
|
260
|
-
branch_exists?(@branch)
|
261
|
-
end
|
262
|
-
|
263
266
|
# Does @branch exist in the current git repo?
|
264
267
|
def branch_exists?(branch)
|
265
268
|
execute("git show-ref '#{branch}'", true) do |result|
|
data/lib/git_fame/version.rb
CHANGED
data/spec/bin_spec.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
describe "bin/git-fame" do
|
2
|
+
it "should include the authors name" do
|
3
|
+
run("--help").should include_output("Linus Oleander")
|
4
|
+
end
|
5
|
+
|
6
|
+
it "should include the the current version" do
|
7
|
+
run("--version").should include_output(GitFame::VERSION)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should fail on invalid option" do
|
11
|
+
run("--nope").should_not be_a_succees
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should not accept a non-existent repository" do
|
15
|
+
run("--repository=??").should_not be_a_succees
|
16
|
+
end
|
17
|
+
|
18
|
+
[
|
19
|
+
"--sort=name",
|
20
|
+
"--sort=commits",
|
21
|
+
"--sort=loc",
|
22
|
+
"--sort=files",
|
23
|
+
"--progressbar=0",
|
24
|
+
"--progressbar=1",
|
25
|
+
"--whitespace",
|
26
|
+
"--bytype",
|
27
|
+
"--include=hello",
|
28
|
+
"--exclude=hello",
|
29
|
+
"--extension=rb,ln",
|
30
|
+
"--branch=master",
|
31
|
+
"--format=csv",
|
32
|
+
"--format=pretty",
|
33
|
+
"--version",
|
34
|
+
"--help"
|
35
|
+
].each do |option|
|
36
|
+
it "should support #{option}" do
|
37
|
+
run(option).should be_a_succees
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should sort by loc by default" do
|
42
|
+
run("--sort=loc", "--progressbar=0").first.should eq(run("--progressbar=0").first)
|
43
|
+
end
|
44
|
+
end
|
data/spec/git_fame_spec.rb
CHANGED
@@ -158,5 +158,17 @@ describe GitFame::Base do
|
|
158
158
|
}).authors
|
159
159
|
}.to raise_error(GitFame::BranchNotFound)
|
160
160
|
end
|
161
|
+
|
162
|
+
it "should not raise on empty branch (use fallback)" do
|
163
|
+
GitFame::Base.new({
|
164
|
+
repository: repository,
|
165
|
+
branch: ""
|
166
|
+
}).authors.should_not be_empty
|
167
|
+
|
168
|
+
GitFame::Base.new({
|
169
|
+
repository: repository,
|
170
|
+
branch: nil
|
171
|
+
}).authors.should_not be_empty
|
172
|
+
end
|
161
173
|
end
|
162
174
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,9 +3,30 @@ require "git_fame"
|
|
3
3
|
require "coveralls"
|
4
4
|
require "rspec/collection_matchers"
|
5
5
|
require_relative "./support/startup"
|
6
|
+
require "rspec/expectations"
|
6
7
|
|
7
8
|
Coveralls.wear!
|
8
9
|
|
10
|
+
RSpec::Matchers.define :be_a_succees do
|
11
|
+
match do |actual|
|
12
|
+
actual.last
|
13
|
+
end
|
14
|
+
|
15
|
+
failure_message do |actual|
|
16
|
+
"expected command to be a success, but failed"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec::Matchers.define :include_output do |expected|
|
21
|
+
match do |actual|
|
22
|
+
actual.first.include?(expected)
|
23
|
+
end
|
24
|
+
|
25
|
+
failure_message do |actual|
|
26
|
+
"expected #{actual} to include #{expected}, but didn't"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
9
30
|
RSpec.configure do |config|
|
10
31
|
config.include GitFame::Startup
|
11
32
|
config.mock_with :rspec
|
@@ -13,7 +34,7 @@ RSpec.configure do |config|
|
|
13
34
|
config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
|
14
35
|
config.fail_fast = false
|
15
36
|
config.before(:all) do
|
16
|
-
Dir.chdir(repository) {
|
37
|
+
Dir.chdir(repository) { system "git checkout 7ab01bc5a720 > /dev/null 2>&1" }
|
17
38
|
end
|
18
39
|
|
19
40
|
# Remove this line to allow Kernel#puts
|
data/spec/support/startup.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
1
|
+
require "open3"
|
2
|
+
|
1
3
|
module GitFame
|
2
4
|
module Startup
|
3
5
|
def repository
|
4
6
|
File.join(File.dirname(File.dirname(__FILE__)), "fixtures/gash")
|
5
7
|
end
|
8
|
+
|
9
|
+
def binary
|
10
|
+
File.join(File.dirname(File.dirname(__FILE__)), "../bin/git-fame")
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(*args)
|
14
|
+
Open3.popen2e(*([binary] + args), chdir: repository) do |_, out, thread|
|
15
|
+
return [out.read, thread.value.success?]
|
16
|
+
end
|
17
|
+
rescue Errno::ENOENT
|
18
|
+
[$!.message, false]
|
19
|
+
end
|
6
20
|
end
|
7
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git_fame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Linus Oleander
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/git_fame/result.rb
|
164
164
|
- lib/git_fame/silent_progressbar.rb
|
165
165
|
- lib/git_fame/version.rb
|
166
|
+
- spec/bin_spec.rb
|
166
167
|
- spec/git_fame_spec.rb
|
167
168
|
- spec/spec_helper.rb
|
168
169
|
- spec/support/startup.rb
|
@@ -192,6 +193,7 @@ summary: 'Generates awesome stats from git-blame A Ruby wrapper for git-blame.
|
|
192
193
|
data like: - Number of files changed by a user - Number of commits by user - Lines
|
193
194
|
of code by a user'
|
194
195
|
test_files:
|
196
|
+
- spec/bin_spec.rb
|
195
197
|
- spec/git_fame_spec.rb
|
196
198
|
- spec/spec_helper.rb
|
197
199
|
- spec/support/startup.rb
|