Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
d45691788e
commit
cdd95ddd01
4 changed files with 32 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Fix stack trace highlight for PHP
|
||||
merge_request: 22258
|
||||
author:
|
||||
type: fixed
|
|
@ -28,7 +28,7 @@ module Gitlab
|
|||
end
|
||||
|
||||
def highlight_entry_context(filename, context)
|
||||
language = Rouge::Lexer.guess_by_filename(filename).tag
|
||||
language = guess_language_by_filename(filename)
|
||||
|
||||
context.map do |line_number, line_of_code|
|
||||
[
|
||||
|
@ -38,6 +38,12 @@ module Gitlab
|
|||
]
|
||||
end
|
||||
end
|
||||
|
||||
def guess_language_by_filename(filename)
|
||||
Rouge::Lexer.guess_by_filename(filename).tag
|
||||
rescue Rouge::Guesser::Ambiguous => e
|
||||
e.alternatives.min_by(&:tag)&.tag
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,16 @@ FactoryBot.define do
|
|||
[8, "}\n"]
|
||||
]
|
||||
},
|
||||
{
|
||||
'function' => 'print',
|
||||
'lineNo' => 3,
|
||||
'filename' => 'hello_world.php',
|
||||
'context' => [
|
||||
[1, "// PHP/Hack example\n"],
|
||||
[2, "<?php\n"],
|
||||
[3, "echo 'Hello, World!';\n"]
|
||||
]
|
||||
},
|
||||
{
|
||||
'filename' => 'blank.txt'
|
||||
}
|
||||
|
|
|
@ -48,6 +48,16 @@ describe Gitlab::ErrorTracking::StackTraceHighlightDecorator do
|
|||
[8, '<span id="LC1" class="line" lang="swift"><span class="p">}</span></span>']
|
||||
]
|
||||
},
|
||||
{
|
||||
'function' => 'print',
|
||||
'lineNo' => 3,
|
||||
'filename' => 'hello_world.php',
|
||||
'context' => [
|
||||
[1, '<span id="LC1" class="line" lang="hack"><span class="c1">// PHP/Hack example</span></span>'],
|
||||
[2, '<span id="LC1" class="line" lang="hack"><span class="cp"><?php</span></span>'],
|
||||
[3, '<span id="LC1" class="line" lang="hack"><span class="k">echo</span> <span class="s1">\'Hello, World!\'</span><span class="p">;</span></span>']
|
||||
]
|
||||
},
|
||||
{
|
||||
'filename' => 'blank.txt'
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue