git_fame 2.0.1 → 2.2.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/README.md +1 -0
- data/bin/git-fame +10 -2
- data/lib/git_fame/base.rb +15 -5
- data/lib/git_fame/version.rb +1 -1
- data/spec/bin_spec.rb +11 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56ed28564572151ef8368874a40c3a78b7450bf6
|
4
|
+
data.tar.gz: 69f85cbc4d81f337b6c32963805030329303f5f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/bin/git-fame
CHANGED
@@ -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
|
-
|
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
|
data/lib/git_fame/base.rb
CHANGED
@@ -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
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
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
|
data/lib/git_fame/version.rb
CHANGED
data/spec/bin_spec.rb
CHANGED
@@ -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.
|
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("
|
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
|