Commit 5d6dc871 authored by Fabio Pitino's avatar Fabio Pitino Committed by Kamil Trzciński

Fix style reset in job log

When ANSI sequence is empty (\e[m) issue a
style reset, same as \e[0m
parent bf24aef3
---
title: Fix style reset in job log when empty ANSI sequence is encoutered
merge_request: 20367
author:
type: fixed
......@@ -15,14 +15,10 @@ module Gitlab
end
def update(ansi_commands)
command = ansi_commands.shift
return unless command
if changes = Gitlab::Ci::Ansi2json::Parser.new(command, ansi_commands).changes
apply_changes(changes)
end
# treat e\[m as \e[0m
ansi_commands = ['0'] if ansi_commands.empty?
update(ansi_commands)
evaluate_stack_command(ansi_commands)
end
def set?
......@@ -50,6 +46,17 @@ module Gitlab
private
def evaluate_stack_command(ansi_commands)
command = ansi_commands.shift
return unless command
if changes = Gitlab::Ci::Ansi2json::Parser.new(command, ansi_commands).changes
apply_changes(changes)
end
evaluate_stack_command(ansi_commands)
end
def apply_changes(changes)
case
when changes[:reset]
......
......@@ -143,6 +143,7 @@ describe Gitlab::Ci::Ansi2json::Style do
[[], %w[106], 'term-bg-l-cyan', 'sets bg color light cyan'],
[[], %w[107], 'term-bg-l-white', 'sets bg color light white'],
# reset
[%w[1], %w[], '', 'resets style from format bold'],
[%w[1], %w[0], '', 'resets style from format bold'],
[%w[1 3], %w[0], '', 'resets style from format bold and italic'],
[%w[1 3 term-fg-l-red term-bg-yellow], %w[0], '', 'resets all formats and colors'],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment