git_fame 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f884e24c83b7a966af59ab96a045ea3ece06b6ff
4
- data.tar.gz: fa4e2967c967867b568ace60dc7bd62bf1a191d4
3
+ metadata.gz: fd0e84253d48334aadecae9770216086d4ac67e7
4
+ data.tar.gz: af9f1a996b0e68e4d537cfe456319d66f66c9c1a
5
5
  SHA512:
6
- metadata.gz: a3f5a220b5e3a6211c3d8aad13d881bcb500e1e0bff4ad8b16bf984e0038c3acd1f4d1673ee6577a495d7be8387fe5c24d33b6f6f612010cee8d0e5084781d79
7
- data.tar.gz: 53101b66a4a44b3eabf739c43bbabf33664e5ccbcee1225566e2dcf41aeb47217eac3225b945f2870de0549c7e89854c8fca6ddf29c31c82d4fb1846b441dab3
6
+ metadata.gz: da9a68656473b6c1bfaefad0bab00634b2ff0f5fafd8b999ebc695ead627e4b3340ff80a6ce5409ac122a81a5e99eae73c6d7ce337f910cf94b6c62ef9cf151b
7
+ data.tar.gz: 87fbb2d5a0f67140eb55929ef1e5ec1aedc7169c711337425873ee652579f52f1bda3f805dce5d1d419cd36f0a320a8cffd89eaf58a47864e72b584170034801
@@ -6,7 +6,7 @@ rvm:
6
6
  - 2.0.0
7
7
  - 1.9.3
8
8
  script:
9
- - 'rspec spec/git_fame_spec.rb --format documentation'
9
+ - 'rspec spec --format documentation'
10
10
  notifications:
11
11
  webhooks:
12
12
  urls:
@@ -1,4 +1,6 @@
1
- #!/usr/bin/env ruby -w
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
2
4
 
3
5
  require "git_fame"
4
6
  require "trollop"
@@ -39,9 +39,13 @@ module GitFame
39
39
  @bytype = args.fetch(:bytype, false)
40
40
  @branch = args.fetch(:branch, default_branch)
41
41
 
42
- # User defined branch must exist
43
- if not blank?(@branch) and not default_branch_exists?
44
- raise GitFame::BranchNotFound, "Branch '#{@branch}' does not exist"
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|
@@ -1,3 +1,3 @@
1
1
  module GitFame
2
- VERSION = "1.7.1"
2
+ VERSION = "1.7.2"
3
3
  end
@@ -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
@@ -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
@@ -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) { `git checkout 7ab01bc5a720` }
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
@@ -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.1
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