airbrake-ruby 6.1.0-java → 6.1.1-java
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/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/nested_exception.rb +10 -1
- data/lib/airbrake-ruby/notice.rb +5 -3
- data/lib/airbrake-ruby/version.rb +1 -1
- metadata +4 -122
- data/spec/airbrake_spec.rb +0 -522
- data/spec/async_sender_spec.rb +0 -65
- data/spec/backtrace_spec.rb +0 -430
- data/spec/benchmark_spec.rb +0 -35
- data/spec/code_hunk_spec.rb +0 -124
- data/spec/config/processor_spec.rb +0 -167
- data/spec/config/validator_spec.rb +0 -204
- data/spec/config_spec.rb +0 -188
- data/spec/context_spec.rb +0 -54
- data/spec/deploy_notifier_spec.rb +0 -50
- data/spec/file_cache_spec.rb +0 -35
- data/spec/filter_chain_spec.rb +0 -124
- data/spec/filters/context_filter_spec.rb +0 -32
- data/spec/filters/dependency_filter_spec.rb +0 -14
- data/spec/filters/exception_attributes_filter_spec.rb +0 -52
- data/spec/filters/gem_root_filter_spec.rb +0 -44
- data/spec/filters/git_last_checkout_filter_spec.rb +0 -61
- data/spec/filters/git_repository_filter_spec.rb +0 -72
- data/spec/filters/git_revision_filter_spec.rb +0 -126
- data/spec/filters/keys_allowlist_spec.rb +0 -204
- data/spec/filters/keys_blocklist_spec.rb +0 -242
- data/spec/filters/root_directory_filter_spec.rb +0 -39
- data/spec/filters/sql_filter_spec.rb +0 -274
- data/spec/filters/system_exit_filter_spec.rb +0 -16
- data/spec/filters/thread_filter_spec.rb +0 -281
- data/spec/fixtures/notroot.txt +0 -7
- data/spec/fixtures/project_root/code.rb +0 -221
- data/spec/fixtures/project_root/empty_file.rb +0 -0
- data/spec/fixtures/project_root/long_line.txt +0 -1
- data/spec/fixtures/project_root/short_file.rb +0 -3
- data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
- data/spec/helpers.rb +0 -9
- data/spec/ignorable_spec.rb +0 -14
- data/spec/inspectable_spec.rb +0 -45
- data/spec/loggable_spec.rb +0 -17
- data/spec/monotonic_time_spec.rb +0 -25
- data/spec/nested_exception_spec.rb +0 -73
- data/spec/notice_notifier/options_spec.rb +0 -269
- data/spec/notice_notifier_spec.rb +0 -361
- data/spec/notice_spec.rb +0 -300
- data/spec/performance_breakdown_spec.rb +0 -11
- data/spec/performance_notifier_spec.rb +0 -645
- data/spec/promise_spec.rb +0 -203
- data/spec/query_spec.rb +0 -11
- data/spec/queue_spec.rb +0 -18
- data/spec/remote_settings/callback_spec.rb +0 -162
- data/spec/remote_settings/settings_data_spec.rb +0 -348
- data/spec/remote_settings_spec.rb +0 -201
- data/spec/request_spec.rb +0 -9
- data/spec/response_spec.rb +0 -110
- data/spec/spec_helper.rb +0 -100
- data/spec/stashable_spec.rb +0 -23
- data/spec/stat_spec.rb +0 -39
- data/spec/sync_sender_spec.rb +0 -168
- data/spec/tdigest_spec.rb +0 -235
- data/spec/thread_pool_spec.rb +0 -196
- data/spec/time_truncate_spec.rb +0 -30
- data/spec/timed_trace_spec.rb +0 -127
- data/spec/truncator_spec.rb +0 -267
data/spec/filter_chain_spec.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::FilterChain do
|
2
|
-
subject(:filter_chain) { described_class.new }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
|
6
|
-
describe "#refine" do
|
7
|
-
let(:filter) do
|
8
|
-
Class.new do
|
9
|
-
attr_reader :weight
|
10
|
-
|
11
|
-
def initialize(weight)
|
12
|
-
@weight = weight
|
13
|
-
end
|
14
|
-
|
15
|
-
def call(notice)
|
16
|
-
notice[:params][:bingo] << @weight
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it "executes filters from heaviest to lightest" do
|
22
|
-
notice[:params][:bingo] = []
|
23
|
-
|
24
|
-
(0...3).reverse_each { |i| filter_chain.add_filter(filter.new(i)) }
|
25
|
-
filter_chain.refine(notice)
|
26
|
-
|
27
|
-
expect(notice[:params][:bingo]).to eq([2, 1, 0])
|
28
|
-
end
|
29
|
-
|
30
|
-
it "stops execution once a notice was ignored" do
|
31
|
-
f2 = filter.new(2)
|
32
|
-
allow(f2).to receive(:call)
|
33
|
-
|
34
|
-
f1 = proc { |notice| notice.ignore! }
|
35
|
-
|
36
|
-
f0 = filter.new(-1)
|
37
|
-
allow(f0).to receive(:call)
|
38
|
-
|
39
|
-
[f2, f1, f0].each { |f| filter_chain.add_filter(f) }
|
40
|
-
|
41
|
-
filter_chain.refine(notice)
|
42
|
-
|
43
|
-
expect(f2).to have_received(:call)
|
44
|
-
expect(f0).not_to have_received(:call)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "#delete_filter" do
|
49
|
-
let(:filter) do
|
50
|
-
Class.new do
|
51
|
-
class << self
|
52
|
-
def name
|
53
|
-
'FooFilter'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def initialize(foo)
|
58
|
-
@foo = foo
|
59
|
-
end
|
60
|
-
|
61
|
-
def call(notice)
|
62
|
-
notice[:params][:foo] << @foo
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it "deletes a class filter" do
|
68
|
-
notice[:params][:foo] = []
|
69
|
-
|
70
|
-
f1 = filter.new(1)
|
71
|
-
filter_chain.add_filter(f1)
|
72
|
-
|
73
|
-
foo_filter_mock = double
|
74
|
-
allow(foo_filter_mock).to receive(:name).at_least(:once).and_return('FooFilter')
|
75
|
-
filter_chain.delete_filter(foo_filter_mock)
|
76
|
-
|
77
|
-
expect(foo_filter_mock).to have_received(:name)
|
78
|
-
|
79
|
-
f2 = filter.new(2)
|
80
|
-
filter_chain.add_filter(f2)
|
81
|
-
|
82
|
-
filter_chain.refine(notice)
|
83
|
-
expect(notice[:params][:foo]).to eq([2])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "#inspect" do
|
88
|
-
it "returns a string representation of an empty FilterChain" do
|
89
|
-
expect(filter_chain.inspect).to eq('[]')
|
90
|
-
end
|
91
|
-
|
92
|
-
it "returns a string representation of a non-empty FilterChain" do
|
93
|
-
filter_chain.add_filter(proc {})
|
94
|
-
expect(filter_chain.inspect).to eq('[Proc]')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe "#includes?" do
|
99
|
-
context "when a custom filter class is included in the filter chain" do
|
100
|
-
it "returns true" do
|
101
|
-
klass = Class.new
|
102
|
-
|
103
|
-
filter_chain.add_filter(klass.new)
|
104
|
-
expect(filter_chain.includes?(klass)).to be(true)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
context "when Proc filter class is included in the filter chain" do
|
109
|
-
it "returns true" do
|
110
|
-
filter_chain.add_filter(proc {})
|
111
|
-
expect(filter_chain.includes?(Proc)).to be(true)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context "when filter class is NOT included in the filter chain" do
|
116
|
-
it "returns false" do
|
117
|
-
klass = Class.new
|
118
|
-
|
119
|
-
filter_chain.add_filter(proc {})
|
120
|
-
expect(filter_chain.includes?(klass)).to be(false)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::ContextFilter do
|
2
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
3
|
-
|
4
|
-
context "when the current context is empty" do
|
5
|
-
it "doesn't merge anything with params" do
|
6
|
-
described_class.new.call(notice)
|
7
|
-
expect(notice[:params]).to be_empty
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
context "when the current context has some data" do
|
12
|
-
it "merges the data with params" do
|
13
|
-
Airbrake.merge_context(apples: 'oranges')
|
14
|
-
described_class.new.call(notice)
|
15
|
-
expect(notice[:params]).to eq(airbrake_context: { apples: 'oranges' })
|
16
|
-
end
|
17
|
-
|
18
|
-
it "clears the data from the current context" do
|
19
|
-
context = { apples: 'oranges' }
|
20
|
-
Airbrake.merge_context(context)
|
21
|
-
described_class.new.call(notice)
|
22
|
-
expect(Airbrake::Context.current).to be_empty
|
23
|
-
end
|
24
|
-
|
25
|
-
it "does not mutate the provided context object" do
|
26
|
-
context = { apples: 'oranges' }
|
27
|
-
Airbrake.merge_context(context)
|
28
|
-
described_class.new.call(notice)
|
29
|
-
expect(context).to match(apples: 'oranges')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::DependencyFilter do
|
2
|
-
subject(:dependency_filter) { described_class.new }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
|
6
|
-
describe "#call" do
|
7
|
-
it "attaches loaded dependencies to context/versions/dependencies" do
|
8
|
-
dependency_filter.call(notice)
|
9
|
-
expect(notice[:context][:versions][:dependencies]).to include(
|
10
|
-
'airbrake-ruby' => Airbrake::AIRBRAKE_RUBY_VERSION,
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::ExceptionAttributesFilter do
|
2
|
-
subject(:exception_attributes_filter) { described_class.new }
|
3
|
-
|
4
|
-
describe "#call" do
|
5
|
-
let(:notice) { Airbrake::Notice.new(ex) }
|
6
|
-
|
7
|
-
context "when #to_airbrake returns a non-Hash object" do
|
8
|
-
let(:ex) do
|
9
|
-
Class.new(AirbrakeTestError) do
|
10
|
-
def to_airbrake
|
11
|
-
Object.new
|
12
|
-
end
|
13
|
-
end.new
|
14
|
-
end
|
15
|
-
|
16
|
-
it "doesn't raise" do
|
17
|
-
expect { exception_attributes_filter.call(notice) }.not_to raise_error
|
18
|
-
expect(notice[:params]).to be_empty
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context "when #to_airbrake errors out" do
|
23
|
-
let(:ex) do
|
24
|
-
Class.new(AirbrakeTestError) do
|
25
|
-
def to_airbrake
|
26
|
-
1 / 0
|
27
|
-
end
|
28
|
-
end.new
|
29
|
-
end
|
30
|
-
|
31
|
-
it "doesn't raise" do
|
32
|
-
expect { exception_attributes_filter.call(notice) }.not_to raise_error
|
33
|
-
expect(notice[:params]).to be_empty
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context "when #to_airbrake returns a hash" do
|
38
|
-
let(:ex) do
|
39
|
-
Class.new(AirbrakeTestError) do
|
40
|
-
def to_airbrake
|
41
|
-
{ params: { foo: '1' } }
|
42
|
-
end
|
43
|
-
end.new
|
44
|
-
end
|
45
|
-
|
46
|
-
it "merges parameters with the notice" do
|
47
|
-
exception_attributes_filter.call(notice)
|
48
|
-
expect(notice[:params]).to eq(foo: '1')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::GemRootFilter do
|
2
|
-
subject(:gem_root_filter) { described_class.new }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
let(:root1) { '/my/gem/root' }
|
6
|
-
let(:root2) { '/my/other/gem/root' }
|
7
|
-
|
8
|
-
before { Gem.path << root1 << root2 }
|
9
|
-
|
10
|
-
after { 2.times { Gem.path.pop } }
|
11
|
-
|
12
|
-
it "replaces gem root in the backtrace with a label" do
|
13
|
-
# rubocop:disable Layout/LineLength
|
14
|
-
notice[:errors].first[:backtrace] = [
|
15
|
-
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
16
|
-
{ file: "#{root1}/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
|
17
|
-
{ file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
|
18
|
-
{ file: "#{root2}/gems/rspec-core-3.3.2/exe/rspec" },
|
19
|
-
]
|
20
|
-
# rubocop:enable Layout/LineLength
|
21
|
-
|
22
|
-
gem_root_filter.call(notice)
|
23
|
-
|
24
|
-
# rubocop:disable Layout/LineLength
|
25
|
-
expect(notice[:errors].first[:backtrace]).to(
|
26
|
-
eq(
|
27
|
-
[
|
28
|
-
{ file: "/home/kyrylo/code/airbrake/ruby/spec/spec_helper.rb" },
|
29
|
-
{ file: "/GEM_ROOT/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb" },
|
30
|
-
{ file: "/opt/rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb" },
|
31
|
-
{ file: "/GEM_ROOT/gems/rspec-core-3.3.2/exe/rspec" },
|
32
|
-
],
|
33
|
-
),
|
34
|
-
)
|
35
|
-
# rubocop:enable Layout/LineLength
|
36
|
-
end
|
37
|
-
|
38
|
-
it "does not filter file when it is nil" do
|
39
|
-
expect(notice[:errors].first[:file]).to be_nil
|
40
|
-
expect { gem_root_filter.call(notice) }.not_to(
|
41
|
-
change { notice[:errors].first[:file] },
|
42
|
-
)
|
43
|
-
end
|
44
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::GitLastCheckoutFilter do
|
2
|
-
subject(:git_last_checkout_filter) { described_class.new('.') }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
|
6
|
-
context "when context/lastCheckout is defined" do
|
7
|
-
it "doesn't attach anything to context/lastCheckout" do
|
8
|
-
notice[:context][:lastCheckout] = '123'
|
9
|
-
git_last_checkout_filter.call(notice)
|
10
|
-
expect(notice[:context][:lastCheckout]).to eq('123')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when .git directory doesn't exist" do
|
15
|
-
subject(:git_last_checkout_without_git_dir_filter) { described_class.new('root/dir') }
|
16
|
-
|
17
|
-
it "doesn't attach anything to context/lastCheckout" do
|
18
|
-
git_last_checkout_without_git_dir_filter.call(notice)
|
19
|
-
expect(notice[:context][:lastCheckout]).to be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when .git directory exists" do
|
24
|
-
context "when AIRBRAKE_DEPLOY_USERNAME env variable is set" do
|
25
|
-
before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = 'deployer' }
|
26
|
-
|
27
|
-
it "attaches username from the environment" do
|
28
|
-
git_last_checkout_filter.call(notice)
|
29
|
-
expect(notice[:context][:lastCheckout][:username]).to eq('deployer')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "when AIRBRAKE_DEPLOY_USERNAME env variable is NOT set" do
|
34
|
-
before { ENV['AIRBRAKE_DEPLOY_USERNAME'] = nil }
|
35
|
-
|
36
|
-
it "attaches last checkouted username" do
|
37
|
-
git_last_checkout_filter.call(notice)
|
38
|
-
username = notice[:context][:lastCheckout][:username]
|
39
|
-
expect(username).not_to be_empty
|
40
|
-
expect(username).not_to be_nil
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "attaches last checkouted email" do
|
45
|
-
git_last_checkout_filter.call(notice)
|
46
|
-
expect(notice[:context][:lastCheckout][:email]).to(match(/\A\w+@[\w\-.]+\z/))
|
47
|
-
end
|
48
|
-
|
49
|
-
it "attaches last checkouted revision" do
|
50
|
-
git_last_checkout_filter.call(notice)
|
51
|
-
expect(notice[:context][:lastCheckout][:revision]).not_to be_empty
|
52
|
-
expect(notice[:context][:lastCheckout][:revision].size).to eq(40)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "attaches last checkouted time" do
|
56
|
-
git_last_checkout_filter.call(notice)
|
57
|
-
expect(notice[:context][:lastCheckout][:time]).not_to be_empty
|
58
|
-
expect(notice[:context][:lastCheckout][:time].size).to eq(25)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::GitRepositoryFilter do
|
2
|
-
subject(:git_repository_filter) { described_class.new('.') }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
|
6
|
-
describe "#initialize" do
|
7
|
-
it "parses standard git version" do
|
8
|
-
allow_any_instance_of(Kernel)
|
9
|
-
.to receive(:`).and_return('git version 2.18.0')
|
10
|
-
expect { git_repository_filter }.not_to raise_error
|
11
|
-
end
|
12
|
-
|
13
|
-
it "parses release candidate git version" do
|
14
|
-
allow_any_instance_of(Kernel)
|
15
|
-
.to receive(:`).and_return('git version 2.21.0-rc0')
|
16
|
-
expect { git_repository_filter }.not_to raise_error
|
17
|
-
end
|
18
|
-
|
19
|
-
it "parses git version with brackets" do
|
20
|
-
allow_any_instance_of(Kernel)
|
21
|
-
.to receive(:`).and_return('git version 2.17.2 (Apple Git-113)')
|
22
|
-
expect { git_repository_filter }.not_to raise_error
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when Errno::EAGAIN is raised when detecting git version" do
|
26
|
-
it "doesn't attach anything to context/repository" do
|
27
|
-
allow_any_instance_of(Kernel).to receive(:`).and_raise(Errno::EAGAIN)
|
28
|
-
git_repository_filter.call(notice)
|
29
|
-
expect(notice[:context][:repository]).to be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when context/repository is defined" do
|
35
|
-
it "doesn't attach anything to context/repository" do
|
36
|
-
notice[:context][:repository] = 'git@github.com:kyrylo/test.git'
|
37
|
-
git_repository_filter.call(notice)
|
38
|
-
expect(notice[:context][:repository]).to eq('git@github.com:kyrylo/test.git')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when .git directory doesn't exist" do
|
43
|
-
subject(:git_repository_filter) { described_class.new('root/dir') }
|
44
|
-
|
45
|
-
it "doesn't attach anything to context/repository" do
|
46
|
-
git_repository_filter.call(notice)
|
47
|
-
expect(notice[:context][:repository]).to be_nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context "when .git directory exists" do
|
52
|
-
it "attaches context/repository" do
|
53
|
-
git_repository_filter.call(notice)
|
54
|
-
expect(notice[:context][:repository]).to match(
|
55
|
-
'github.com/airbrake/airbrake-ruby',
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "when git is not in PATH" do
|
61
|
-
let!(:path) { ENV['PATH'] }
|
62
|
-
|
63
|
-
before { ENV['PATH'] = '' }
|
64
|
-
|
65
|
-
after { ENV['PATH'] = path }
|
66
|
-
|
67
|
-
it "does not attach context/repository" do
|
68
|
-
git_repository_filter.call(notice)
|
69
|
-
expect(notice[:context][:repository]).to be_nil
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::GitRevisionFilter do
|
2
|
-
subject(:git_revision_filter) { described_class.new('root/dir') }
|
3
|
-
|
4
|
-
# 'let!', not 'let' to make sure Notice doesn't call File.exist? with
|
5
|
-
# unexpected arguments.
|
6
|
-
let!(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
7
|
-
|
8
|
-
context "when context/revision is defined" do
|
9
|
-
it "doesn't attach anything to context/revision" do
|
10
|
-
notice[:context][:revision] = '1.2.3'
|
11
|
-
git_revision_filter.call(notice)
|
12
|
-
expect(notice[:context][:revision]).to eq('1.2.3')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
context "when .git directory doesn't exist" do
|
17
|
-
it "doesn't attach anything to context/revision" do
|
18
|
-
git_revision_filter.call(notice)
|
19
|
-
expect(notice[:context][:revision]).to be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context "when .git directory exists" do
|
24
|
-
before do
|
25
|
-
allow(File).to receive(:exist?).with('root/dir/.git').and_return(true)
|
26
|
-
end
|
27
|
-
|
28
|
-
context "and when HEAD doesn't exist" do
|
29
|
-
before do
|
30
|
-
allow(File).to receive(:exist?).with('root/dir/.git/HEAD').and_return(false)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "doesn't attach anything to context/revision" do
|
34
|
-
git_revision_filter.call(notice)
|
35
|
-
expect(notice[:context][:revision]).to be_nil
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "and when HEAD exists" do
|
40
|
-
before do
|
41
|
-
allow(File).to receive(:exist?).with('root/dir/.git/HEAD').and_return(true)
|
42
|
-
end
|
43
|
-
|
44
|
-
context "and also when HEAD doesn't start with 'ref: '" do
|
45
|
-
before do
|
46
|
-
allow(File).to(
|
47
|
-
receive(:read).with('root/dir/.git/HEAD').and_return('refs/foo'),
|
48
|
-
)
|
49
|
-
end
|
50
|
-
|
51
|
-
it "attaches the content of HEAD to context/revision" do
|
52
|
-
git_revision_filter.call(notice)
|
53
|
-
expect(notice[:context][:revision]).to eq('refs/foo')
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
context "and also when HEAD starts with 'ref: '" do
|
58
|
-
before do
|
59
|
-
allow(File).to(
|
60
|
-
receive(:read).with('root/dir/.git/HEAD').and_return("ref: refs/foo\n"),
|
61
|
-
)
|
62
|
-
end
|
63
|
-
|
64
|
-
context "when the ref exists" do
|
65
|
-
before do
|
66
|
-
allow(File).to(
|
67
|
-
receive(:exist?).with('root/dir/.git/refs/foo').and_return(true),
|
68
|
-
)
|
69
|
-
allow(File).to(
|
70
|
-
receive(:read).with('root/dir/.git/refs/foo').and_return("d34db33f\n"),
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
it "attaches the revision from the ref to context/revision" do
|
75
|
-
git_revision_filter.call(notice)
|
76
|
-
expect(notice[:context][:revision]).to eq('d34db33f')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when the ref doesn't exist" do
|
81
|
-
before do
|
82
|
-
allow(File).to(
|
83
|
-
receive(:exist?).with('root/dir/.git/refs/foo').and_return(false),
|
84
|
-
)
|
85
|
-
end
|
86
|
-
|
87
|
-
context "and when '.git/packed-refs' exists" do
|
88
|
-
before do
|
89
|
-
allow(File).to(
|
90
|
-
receive(:exist?).with('root/dir/.git/packed-refs').and_return(true),
|
91
|
-
)
|
92
|
-
allow(File).to(
|
93
|
-
receive(:readlines).with('root/dir/.git/packed-refs').and_return(
|
94
|
-
[
|
95
|
-
"# pack-refs with: peeled fully-peeled\n",
|
96
|
-
"ccb316eecff79c7528d1ad43e5fa165f7a44d52e refs/tags/v3.0.30\n",
|
97
|
-
"^d358900f73ee5bfd6ca3a592cf23ac6e82df83c1",
|
98
|
-
"d34db33f refs/foo\n",
|
99
|
-
],
|
100
|
-
),
|
101
|
-
)
|
102
|
-
end
|
103
|
-
|
104
|
-
it "attaches the revision from 'packed-refs' to context/revision" do
|
105
|
-
git_revision_filter.call(notice)
|
106
|
-
expect(notice[:context][:revision]).to eq('d34db33f')
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context "and when '.git/packed-refs' doesn't exist" do
|
111
|
-
before do
|
112
|
-
allow(File).to(
|
113
|
-
receive(:exist?).with('root/dir/.git/packed-refs').and_return(false),
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
it "attaches the content of HEAD to context/revision" do
|
118
|
-
git_revision_filter.call(notice)
|
119
|
-
expect(notice[:context][:revision]).to eq('refs/foo')
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|