rspec-tracer 0.7.0 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +26 -0
- data/README.md +331 -260
- data/lib/rspec_tracer/cache.rb +8 -3
- data/lib/rspec_tracer/configuration.rb +12 -23
- data/lib/rspec_tracer/html_reporter/reporter.rb +15 -3
- data/lib/rspec_tracer/remote_cache/aws.rb +178 -0
- data/lib/rspec_tracer/remote_cache/cache.rb +36 -144
- data/lib/rspec_tracer/remote_cache/repo.rb +175 -0
- data/lib/rspec_tracer/remote_cache/validator.rb +52 -0
- data/lib/rspec_tracer/reporter.rb +79 -4
- data/lib/rspec_tracer/rspec_runner.rb +14 -4
- data/lib/rspec_tracer/runner.rb +29 -0
- data/lib/rspec_tracer/version.rb +1 -1
- data/lib/rspec_tracer.rb +17 -13
- metadata +13 -8
- data/lib/rspec_tracer/remote_cache/git.rb +0 -113
@@ -1,113 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RSpecTracer
|
4
|
-
module RemoteCache
|
5
|
-
class Git
|
6
|
-
class GitOperationError < StandardError; end
|
7
|
-
|
8
|
-
attr_reader :branch_ref, :ref_list
|
9
|
-
|
10
|
-
def initialize
|
11
|
-
fetch_head_ref
|
12
|
-
fetch_branch_ref
|
13
|
-
end
|
14
|
-
|
15
|
-
def prepare_for_download
|
16
|
-
fetch_unreachable_refs
|
17
|
-
fetch_ancestry_refs
|
18
|
-
fetch_ordered_refs
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def fetch_head_ref
|
24
|
-
@head_ref = `git rev-parse HEAD`.chomp
|
25
|
-
|
26
|
-
raise GitOperationError, 'Could not find HEAD commit sha' unless $CHILD_STATUS.success?
|
27
|
-
end
|
28
|
-
|
29
|
-
def fetch_branch_ref
|
30
|
-
@merged_parents = []
|
31
|
-
@ignored_refs = []
|
32
|
-
|
33
|
-
unless merged?
|
34
|
-
@branch_ref = @head_ref
|
35
|
-
|
36
|
-
return
|
37
|
-
end
|
38
|
-
|
39
|
-
@ignored_refs << @head_ref
|
40
|
-
|
41
|
-
fetch_merged_parents
|
42
|
-
fetch_merged_branch_ref
|
43
|
-
end
|
44
|
-
|
45
|
-
def merged?
|
46
|
-
system('git', 'rev-parse', 'HEAD^2', out: File::NULL, err: File::NULL)
|
47
|
-
end
|
48
|
-
|
49
|
-
def fetch_merged_parents
|
50
|
-
first_parent = `git rev-parse HEAD^1`.chomp
|
51
|
-
@merged_parents << first_parent if $CHILD_STATUS.success?
|
52
|
-
|
53
|
-
second_parent = `git rev-parse HEAD^2`.chomp
|
54
|
-
@merged_parents << second_parent if $CHILD_STATUS.success?
|
55
|
-
|
56
|
-
raise GitOperationError, 'Could not find merged commit parents' if @merged_parents.length != 2
|
57
|
-
end
|
58
|
-
|
59
|
-
def fetch_merged_branch_ref
|
60
|
-
@origin_head_ref = `git rev-parse origin/HEAD`.chomp
|
61
|
-
@branch_ref = nil
|
62
|
-
|
63
|
-
if @merged_parents.first != @origin_head_ref
|
64
|
-
@branch_ref = @head_ref
|
65
|
-
@ignored_refs = []
|
66
|
-
|
67
|
-
return
|
68
|
-
end
|
69
|
-
|
70
|
-
@branch_ref = @merged_parents.last
|
71
|
-
@ignored_refs = @ignored_refs.to_set | `git rev-list #{@branch_ref}..origin/HEAD`.chomp.split
|
72
|
-
|
73
|
-
raise GitOperationError, 'Could not find ignored refs' unless $CHILD_STATUS.success?
|
74
|
-
end
|
75
|
-
|
76
|
-
def fetch_unreachable_refs
|
77
|
-
command = <<-COMMAND.strip.gsub(/\s+/, ' ')
|
78
|
-
git fsck
|
79
|
-
--no-progress
|
80
|
-
--unreachable
|
81
|
-
--connectivity-only #{@branch_ref}
|
82
|
-
| awk '/commit/ { print $3 }'
|
83
|
-
| head -n 25
|
84
|
-
COMMAND
|
85
|
-
|
86
|
-
@unreachable_refs = `#{command}`.chomp.split
|
87
|
-
|
88
|
-
raise GitOperationError, 'Could not find unreachable refs' unless $CHILD_STATUS.success?
|
89
|
-
end
|
90
|
-
|
91
|
-
def fetch_ancestry_refs
|
92
|
-
@ancestry_refs = `git rev-list --max-count=25 #{@branch_ref}`.chomp.split
|
93
|
-
|
94
|
-
raise GitOperationError, 'Could not find ancestry refs' unless $CHILD_STATUS.success?
|
95
|
-
end
|
96
|
-
|
97
|
-
def fetch_ordered_refs
|
98
|
-
unordered_refs = (@unreachable_refs.to_set | @ancestry_refs) - @ignored_refs
|
99
|
-
|
100
|
-
command = <<-COMMAND.strip.gsub(/\s+/, ' ')
|
101
|
-
git rev-list
|
102
|
-
--topo-order
|
103
|
-
--no-walk=sorted
|
104
|
-
#{unordered_refs.to_a.join(' ')}
|
105
|
-
COMMAND
|
106
|
-
|
107
|
-
@ref_list = `#{command}`.chomp.split
|
108
|
-
|
109
|
-
raise GitOperationError, 'Could not find refs to download cache' unless $CHILD_STATUS.success?
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|