Skip to content

Commit

Permalink
Handle old and new backtrace format, fixes 1477
Browse files Browse the repository at this point in the history
  • Loading branch information
2called-chaos committed Mar 23, 2021
1 parent a4e12ce commit b66e4ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/models/backtrace.rb
Expand Up @@ -2,8 +2,8 @@ class Backtrace
include Mongoid::Document
include Mongoid::Timestamps

IN_APP_PATH = %r{^\[PROJECT_ROOT\](?!(\/vendor))/?}
GEMS_PATH = %r{\[GEM_ROOT\]\/gems\/([^\/]+)}
IN_APP_PATH = %r{^(?:\[|/)PROJECT_ROOT\]?(?!(/vendor))/?}
GEMS_PATH = %r{(?:\[|/)GEM_ROOT\]?/gems/([^/]+)}

field :fingerprint
field :lines
Expand Down
16 changes: 16 additions & 0 deletions spec/decorators/backtrace_line_decorator_spec.rb
Expand Up @@ -11,6 +11,12 @@
file: '[PROJECT_ROOT]/path/to/file/ea315ea4.rb',
method: :instance_eval)
end
let(:backtrace_line_in_app_slashes) do
described_class.new(
number: 884,
file: '/PROJECT_ROOT/path/to/file/ea315ea4.rb',
method: :instance_eval)
end
let(:backtrace_line_no_file) do
described_class.new(number: 884, method: :instance_eval)
end
Expand Down Expand Up @@ -47,6 +53,16 @@
end
end

describe '#decorated_path' do
it 'parses old backtrace format with square brackets' do
expect(backtrace_line_in_app.decorated_path).to eq 'path/to/file/'
end

it 'parses new backtrace format with slashes' do
expect(backtrace_line_in_app_slashes.decorated_path).to eq 'path/to/file/'
end
end

describe '#link_to_source_file' do
it 'adds a link to the source file' do
link = backtrace_line_in_app.link_to_source_file(app) { 'mytext' }
Expand Down

0 comments on commit b66e4ed

Please sign in to comment.