git_fame 2.0.1 → 2.2.0

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: 00cb789b59804a3307424c8bffaafa1c07cee019
4
- data.tar.gz: 211d4c69bd1adcabd848ca660ae83f9369d87654
3
+ metadata.gz: 56ed28564572151ef8368874a40c3a78b7450bf6
4
+ data.tar.gz: 69f85cbc4d81f337b6c32963805030329303f5f8
5
5
  SHA512:
6
- metadata.gz: 65932d6a3744577f3776b6221e8e94fa4283061452264eca0a1533f0c726d99b53e71cdf774200c47c41e5713c82663eb215f7ff97484044a0df51cf705b633b
7
- data.tar.gz: 267729e8610daa3ce854ce18ac7bed062ea01a27c2aaaf72d96095b1e1303f8b6dc1a03f702a7827e75fa53d1891e6efa2d1e85338b98d33cbe18e4c30e6943d
6
+ metadata.gz: bca32c460a55a96cee4cb5673ff371d6695589185e9b86ab3b7ce5e480b59c1f254f996452b8ee10d11d095b7bff122aad67703192607612dadf3d7cd0d30ac1
7
+ data.tar.gz: 05270545850772755df28042a05088a64c6b60566948019834e20fe718b05bb5da1a1cfb3b06b86cae87ec0647342c1bb5b72a7a581abfa0d685faf1f0314c92
data/README.md CHANGED
@@ -49,6 +49,7 @@ From a git repository run `git fame`.
49
49
  - `git fame --before=2016-02-01` Only use commits before this date. Format: yyyy-mm-dd. Note that the given date is included.
50
50
  - `git fame --verbose` Print shell commands used by `git-fame`.
51
51
  - `git fame --everything` Images and binaries are ignored by default. Include them as well.
52
+ - `git fame --timeout` Set timeout in seconds for each git command.
52
53
 
53
54
  #### By type
54
55
 
@@ -20,6 +20,7 @@ opts = Trollop::options do
20
20
  opt :after, "Only use commmits after this date. Format: yyyy-mm-dd. Note that the given date is included", type: String
21
21
  opt :before, "Only use commits before this date. Format: yyyy-mm-dd. Note that the given date is included", type: String
22
22
  opt :verbose, "Print shell commands used by git-fame", default: false
23
+ opt :timeout, "Set timeout in seconds for each git command. Turn off by using -1", type: Integer, default: GitFame::CMD_TIMEOUT
23
24
  opt :everything, "Images and binaries are ignored by default. Include them as well", default: false
24
25
  end
25
26
 
@@ -27,6 +28,10 @@ unless GitFame::SORT.include?(opts[:sort])
27
28
  Trollop::die :sort, "must be one of the following; #{GitFame::SORT.join(", ")}"
28
29
  end
29
30
 
31
+ if opts[:timeout] <= 0
32
+ Trollop::die :timeout, "must be positive"
33
+ end
34
+
30
35
  begin
31
36
  fame = GitFame::Base.new({
32
37
  repository: opts[:repository],
@@ -41,10 +46,13 @@ begin
41
46
  after: opts[:after],
42
47
  before: opts[:before],
43
48
  verbose: opts[:verbose],
44
- everything: opts[:everything]
49
+ everything: opts[:everything],
50
+ timeout: opts[:timeout]
45
51
  })
46
52
 
47
53
  opts[:format] == "csv" ? fame.csv_puts : fame.pretty_puts
48
54
  rescue GitFame::Error => e
49
- abort "Error: #{e.message}"
55
+ Trollop::die e.message
56
+ rescue Timeout::Error
57
+ Trollop::die "Maximum timeout of #{opts[:timeout]} sec exceed. Try passing --timeout=<sec> or -1 for no timeout"
50
58
  end
@@ -56,6 +56,7 @@ module GitFame
56
56
  @by_type = args.fetch(:by_type, false)
57
57
  @branch = args.fetch(:branch, nil)
58
58
  @everything = args.fetch(:everything, false)
59
+ @timeout = args.fetch(:timeout, CMD_TIMEOUT)
59
60
 
60
61
  # Figure out what branch the caller is using
61
62
  if present?(@branch = args[:branch])
@@ -324,10 +325,19 @@ module GitFame
324
325
  end
325
326
 
326
327
  def run(command)
327
- Timeout.timeout(CMD_TIMEOUT) do
328
- Open3.popen2e(command, chdir: @repository) do |_, out, thread|
329
- Result.new(out.read.scrub.strip, thread.value.success?)
330
- end
328
+ if @timeout != -1
329
+ Timeout.timeout(CMD_TIMEOUT) { raw_run(command) }
330
+ else
331
+ raw_run(command)
332
+ end
333
+ end
334
+
335
+ def raw_run(command)
336
+ Open3.popen3(command, chdir: @repository) do |_, out, err, thread|
337
+ out_data = out.read
338
+ err_data = err.read
339
+ output = thread.value.success? ? out_data : err_data
340
+ Result.new(output.scrub.strip, thread.value.success?)
331
341
  end
332
342
  end
333
343
 
@@ -365,7 +375,7 @@ module GitFame
365
375
  # extensions in @extensions defined by the user
366
376
  def current_files
367
377
  if commit_range.is_range?
368
- execute("git diff --name-status #{encoding_opt} #{default_params} #{commit_range.to_s} | grep -v '^D' | cut -f2-") do |result|
378
+ execute("git diff -l 100 --name-status #{encoding_opt} #{default_params} #{commit_range.to_s} | grep -v '^D' | cut -f2-") do |result|
369
379
  filter_files(result)
370
380
  end
371
381
  else
@@ -1,3 +1,3 @@
1
1
  module GitFame
2
- VERSION = "2.0.1"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -33,7 +33,8 @@ describe "bin/git-fame" do
33
33
  "--version",
34
34
  "--help",
35
35
  "--verbose",
36
- "--everything"
36
+ "--everything",
37
+ "--timeout=10"
37
38
  ].each do |option|
38
39
  it "should support #{option}" do
39
40
  run(option).should be_a_succees
@@ -48,13 +49,13 @@ describe "bin/git-fame" do
48
49
  it "should fail on invalid before date" do
49
50
  res = run("--before='---'")
50
51
  res.should_not be_a_succees
51
- res.first.should eq("Error: '---' is not a valid date\n")
52
+ res.should include_output("'---' is not a valid date")
52
53
  end
53
54
 
54
55
  it "should fail on invalid after date" do
55
56
  res = run("--after='---'")
56
57
  res.should_not be_a_succees
57
- res.should include_output("Error: '---' is not a valid date\n")
58
+ res.should include_output("'---' is not a valid date")
58
59
  end
59
60
 
60
61
  it "should not print stack trace on invalid dates (--after)" do
@@ -63,6 +64,13 @@ describe "bin/git-fame" do
63
64
  res.should_not include_output("GitFame::Error")
64
65
  end
65
66
 
67
+ it "should fail on invalid timeout" do
68
+ run("--timeout=hello").should_not be_a_succees
69
+ run("--timeout=").should_not be_a_succees
70
+ run("--timeout=-1").should_not be_a_succees
71
+ run("--timeout=0").should_not be_a_succees
72
+ end
73
+
66
74
  it "should not print stack trace on invalid dates (--before)" do
67
75
  res = run("--before='---'")
68
76
  res.should_not be_a_succees
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: 2.0.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Linus Oleander