Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
e7d3fe44
Commit
e7d3fe44
authored
Apr 17, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only set the encoding before passing to Ansi2html
parent
dac23fa2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
lib/gitlab/ci/trace.rb
lib/gitlab/ci/trace.rb
+0
-2
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+8
-3
spec/lib/gitlab/ci/trace/stream_spec.rb
spec/lib/gitlab/ci/trace/stream_spec.rb
+7
-7
No files found.
lib/gitlab/ci/trace.rb
View file @
e7d3fe44
...
...
@@ -50,8 +50,6 @@ module Gitlab
end
def
read
return
unless
exist?
stream
=
Gitlab
::
Ci
::
Trace
::
Stream
.
new
do
if
current_path
File
.
open
(
current_path
,
"rb"
)
...
...
lib/gitlab/ci/trace/stream.rb
View file @
e7d3fe44
...
...
@@ -14,9 +14,7 @@ module Gitlab
def
initialize
@stream
=
yield
@stream
.
binmode
# Ci::Ansi2html::Converter would read from @stream directly
@stream
.
set_encoding
(
Encoding
.
default_external
)
@stream
.
binmode
if
@stream
end
def
valid?
...
...
@@ -58,12 +56,14 @@ module Gitlab
end
def
html_with_state
(
state
=
nil
)
set_encoding_for_ansi2html
::
Ci
::
Ansi2html
.
convert
(
stream
,
state
)
end
def
html
(
last_lines:
nil
)
text
=
raw
(
last_lines:
last_lines
)
stream
=
StringIO
.
new
(
text
)
set_encoding_for_ansi2html
(
stream
)
::
Ci
::
Ansi2html
.
convert
(
stream
).
html
end
...
...
@@ -117,6 +117,11 @@ module Gitlab
chunks
.
join
.
lines
.
last
(
last_lines
).
join
end
def
set_encoding_for_ansi2html
(
stream
=
@stream
)
# Ci::Ansi2html::Converter would read from @stream directly
stream
.
set_encoding
(
Encoding
.
default_external
)
end
end
end
end
...
...
spec/lib/gitlab/ci/trace/stream_spec.rb
View file @
e7d3fe44
...
...
@@ -34,11 +34,11 @@ describe Gitlab::Ci::Trace::Stream do
end
context
'when the trace contains ANSI sequence and Unicode'
do
let
(
:io
)
do
let
(
:stream
)
do
described_class
.
new
do
File
.
open
(
expand_fixture_path
(
'trace/ansi-sequence-and-unicode'
))
end
let
(
:stream
)
{
described_class
.
new
{
io
}
}
end
it
'forwards to the next linefeed, case 1'
do
stream
.
limit
(
7
)
...
...
@@ -60,11 +60,11 @@ describe Gitlab::Ci::Trace::Stream do
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/30796
it
'reads in binary, output as Encoding.default_external'
do
stream
.
limit
(
29
)
stream
.
limit
(
52
)
result
=
io
.
read
# Ci::Ansi2html::Converter would read with each_line
result
=
stream
.
html
expect
(
result
).
to
eq
(
"
\e
[01;32m許功蓋
\e
[0m
\n
"
)
expect
(
result
.
lines
.
first
).
to
eq
(
"ヾ(´༎ຶД༎ຶ`)ノ<br><span class=
\"
term-fg-green
\"
>許功蓋</span><br>
"
)
expect
(
result
.
encoding
).
to
eq
(
Encoding
.
default_external
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment