diff options
Diffstat (limited to 'lib/gitlab/chat')
-rw-r--r-- | lib/gitlab/chat/output.rb | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/lib/gitlab/chat/output.rb b/lib/gitlab/chat/output.rb index 411b1555a7d..4a55b81a9eb 100644 --- a/lib/gitlab/chat/output.rb +++ b/lib/gitlab/chat/output.rb @@ -12,7 +12,10 @@ module Gitlab PRIMARY_SECTION = 'chat_reply' # The backup trace section in case the primary one could not be found. - FALLBACK_SECTION = 'build_script' + FALLBACK_SECTION = 'step_script' + + # `step_script` used to be `build_script` before runner 13.1 + LEGACY_SECTION = 'build_script' # build - The `Ci::Build` to obtain the output from. def initialize(build) @@ -37,24 +40,6 @@ module Gitlab end end - # Returns the offset to seek to and the number of bytes to read relative - # to the offset. - def read_offset_and_length - section = find_build_trace_section(PRIMARY_SECTION) || - find_build_trace_section(FALLBACK_SECTION) - - unless section - raise( - MissingBuildSectionError, - "The build_script trace section could not be found for build #{build.id}" - ) - end - - length = section[:byte_end] - section[:byte_start] - - [section[:byte_start], length] - end - # Removes the line containing the executed command from the build output. # # output - A `String` containing the output of a trace section. @@ -88,6 +73,27 @@ module Gitlab def trace @trace ||= build.trace end + + private + + # Returns the offset to seek to and the number of bytes to read relative + # to the offset. + def read_offset_and_length + section = find_build_trace_section(PRIMARY_SECTION) || + find_build_trace_section(FALLBACK_SECTION) || + find_build_trace_section(LEGACY_SECTION) + + unless section + raise( + MissingBuildSectionError, + "The build_script trace section could not be found for build #{build.id}" + ) + end + + length = section[:byte_end] - section[:byte_start] + + [section[:byte_start], length] + end end end end |