From cdec9e472db581acbee72cdcaa703e4155cb4cfb Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 23 May 2016 20:38:30 -0500 Subject: [PATCH] Replace \n to
--- app/assets/javascripts/ci/build.coffee | 6 ++++-- lib/ci/ansi2html.rb | 4 +++- spec/lib/ci/ansi2html_spec.rb | 9 +++++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/ci/build.coffee b/app/assets/javascripts/ci/build.coffee index d700742e4a..98d05e4127 100644 --- a/app/assets/javascripts/ci/build.coffee +++ b/app/assets/javascripts/ci/build.coffee @@ -33,8 +33,10 @@ class CiBuild url: build_url + "/trace.json?state=" + encodeURIComponent(@state) dataType: "json" success: (log) => - if last_state is @state and log.status is "running" - @state = if log.state then log.state else "" + return unless last_state is @state + + if log.state and log.status is "running" + @state = log.state if log.append $('.fa-refresh').before log.html else diff --git a/lib/ci/ansi2html.rb b/lib/ci/ansi2html.rb index c628257e3f..229050151d 100644 --- a/lib/ci/ansi2html.rb +++ b/lib/ci/ansi2html.rb @@ -90,7 +90,7 @@ module Ci def convert(raw, new_state) reset_state - restore_state(raw, new_state) if new_state + restore_state(raw, new_state) if new_state.present? start = @offset ansi = raw[@offset..-1] @@ -105,6 +105,8 @@ module Ci break elsif s.scan(/' else @out << s.scan(/./m) end diff --git a/spec/lib/ci/ansi2html_spec.rb b/spec/lib/ci/ansi2html_spec.rb index 04afbd0692..898f1e84ab 100644 --- a/spec/lib/ci/ansi2html_spec.rb +++ b/spec/lib/ci/ansi2html_spec.rb @@ -175,5 +175,14 @@ describe Ci::Ansi2html, lib: true do it_behaves_like 'stateable converter' end + + context 'with new line' do + let(:pre_text) { "Hello\r" } + let(:pre_html) { "Hello\r" } + let(:text) { "\nWorld" } + let(:html) { "
World" } + + it_behaves_like 'stateable converter' + end end end