Skip to content

Commit

Permalink
feat: match ruby 3.4 backtrace changes (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
tubaxenor authored Jan 16, 2025
1 parent 4909418 commit c56c55d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- 3.1
- 3.2
- 3.3
- 3.4
env:
BUNDLE_GEMFILE: Gemfile
name: "RSpec tests: Ruby ${{ matrix.ruby }}"
Expand Down
2 changes: 1 addition & 1 deletion code_ownership.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'code_ownership'
spec.version = '1.38.1'
spec.version = '1.38.2'
spec.authors = ['Gusto Engineers']
spec.email = ['[email protected]']
spec.summary = 'A gem to help engineering teams declare ownership of code'
Expand Down
24 changes: 17 additions & 7 deletions lib/code_ownership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,23 @@ def backtrace_with_ownership(backtrace)
#
# ./app/controllers/some_controller.rb:43:in `block (3 levels) in create'
#
backtrace_line = %r{\A(#{Pathname.pwd}/|\./)?
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
:
(?<line>\d+) # Matches '43'
:in\s
`(?<function>.*)' # Matches "`block (3 levels) in create'"
\z}x
backtrace_line = if RUBY_VERSION >= '3.4.0'
%r{\A(#{Pathname.pwd}/|\./)?
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
:
(?<line>\d+) # Matches '43'
:in\s
'(?<function>.*)' # Matches "`block (3 levels) in create'"
\z}x
else
%r{\A(#{Pathname.pwd}/|\./)?
(?<file>.+) # Matches 'app/controllers/some_controller.rb'
:
(?<line>\d+) # Matches '43'
:in\s
`(?<function>.*)' # Matches "`block (3 levels) in create'"
\z}x
end

backtrace.lazy.filter_map do |line|
match = line.match(backtrace_line)
Expand Down

0 comments on commit c56c55d

Please sign in to comment.