diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2017-04-17 17:10:41 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-17 17:10:41 +0800 |
commit | e7d3fe44f64d1efbbc0b9611cb3382feff4a2f00 (patch) | |
tree | b23806309abaa4238dd4d24ef9651cfaae292cc9 /lib/gitlab | |
parent | dac23fa233f98b521065fd3f21f6183f84b562d3 (diff) | |
download | gitlab-ce-e7d3fe44f64d1efbbc0b9611cb3382feff4a2f00.tar.gz |
Only set the encoding before passing to Ansi2html
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/ci/trace.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/trace/stream.rb | 11 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb index b980e29e9c3..5b835bb669a 100644 --- a/lib/gitlab/ci/trace.rb +++ b/lib/gitlab/ci/trace.rb @@ -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") diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb index 8d9fb6ff0f1..757a8e2dc6a 100644 --- a/lib/gitlab/ci/trace/stream.rb +++ b/lib/gitlab/ci/trace/stream.rb @@ -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 |