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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
dbb97bb9
Commit
dbb97bb9
authored
Sep 06, 2020
by
Kev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add section_options to job line
parent
711729e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
5 deletions
+26
-5
lib/gitlab/ci/ansi2json/converter.rb
lib/gitlab/ci/ansi2json/converter.rb
+18
-3
lib/gitlab/ci/ansi2json/line.rb
lib/gitlab/ci/ansi2json/line.rb
+6
-1
lib/gitlab/ci/ansi2json/state.rb
lib/gitlab/ci/ansi2json/state.rb
+2
-1
No files found.
lib/gitlab/ci/ansi2json/converter.rb
View file @
dbb97bb9
...
@@ -104,11 +104,12 @@ module Gitlab
...
@@ -104,11 +104,12 @@ module Gitlab
action
=
scanner
[
1
]
action
=
scanner
[
1
]
timestamp
=
scanner
[
2
]
timestamp
=
scanner
[
2
]
section
=
scanner
[
3
]
section
=
scanner
[
3
]
options
=
parse_section_options
(
scanner
[
4
])
section_name
=
sanitize_section_name
(
section
)
section_name
=
sanitize_section_name
(
section
)
if
action
==
"start"
if
action
==
"start"
handle_section_start
(
scanner
,
section_name
,
timestamp
)
handle_section_start
(
scanner
,
section_name
,
timestamp
,
options
)
elsif
action
==
"end"
elsif
action
==
"end"
handle_section_end
(
scanner
,
section_name
,
timestamp
)
handle_section_end
(
scanner
,
section_name
,
timestamp
)
else
else
...
@@ -116,11 +117,11 @@ module Gitlab
...
@@ -116,11 +117,11 @@ module Gitlab
end
end
end
end
def
handle_section_start
(
scanner
,
section
,
timestamp
)
def
handle_section_start
(
scanner
,
section
,
timestamp
,
options
)
# We make a new line for new section
# We make a new line for new section
flush_current_line
flush_current_line
@state
.
open_section
(
section
,
timestamp
)
@state
.
open_section
(
section
,
timestamp
,
options
)
# we need to consume match after handling
# we need to consume match after handling
# the open of section, as we want the section
# the open of section, as we want the section
...
@@ -157,6 +158,20 @@ module Gitlab
...
@@ -157,6 +158,20 @@ module Gitlab
def
sanitize_section_name
(
section
)
def
sanitize_section_name
(
section
)
section
.
to_s
.
downcase
.
gsub
(
/[^a-z0-9]/
,
'-'
)
section
.
to_s
.
downcase
.
gsub
(
/[^a-z0-9]/
,
'-'
)
end
end
def
parse_section_options
(
raw_options
)
return
unless
raw_options
# We need to remove the square brackets and split
# by comma to get a list of the options
options
=
raw_options
[
1
...-
1
].
split
","
# Now split each option by equals to separate
# each in the format [key, value]
options
=
options
.
map
{
|
option
|
option
.
split
"="
}
options
.
to_h
end
end
end
end
end
end
end
...
...
lib/gitlab/ci/ansi2json/line.rb
View file @
dbb97bb9
...
@@ -32,7 +32,7 @@ module Gitlab
...
@@ -32,7 +32,7 @@ module Gitlab
end
end
attr_reader
:offset
,
:sections
,
:segments
,
:current_segment
,
attr_reader
:offset
,
:sections
,
:segments
,
:current_segment
,
:section_header
,
:section_duration
:section_header
,
:section_duration
,
:section_options
def
initialize
(
offset
:,
style
:,
sections:
[])
def
initialize
(
offset
:,
style
:,
sections:
[])
@offset
=
offset
@offset
=
offset
...
@@ -68,6 +68,10 @@ module Gitlab
...
@@ -68,6 +68,10 @@ module Gitlab
@sections
<<
section
@sections
<<
section
end
end
def
set_section_options
(
options
)
@section_options
=
options
end
def
set_as_section_header
def
set_as_section_header
@section_header
=
true
@section_header
=
true
end
end
...
@@ -90,6 +94,7 @@ module Gitlab
...
@@ -90,6 +94,7 @@ module Gitlab
result
[
:section
]
=
sections
.
last
if
sections
.
any?
result
[
:section
]
=
sections
.
last
if
sections
.
any?
result
[
:section_header
]
=
true
if
@section_header
result
[
:section_header
]
=
true
if
@section_header
result
[
:section_duration
]
=
@section_duration
if
@section_duration
result
[
:section_duration
]
=
@section_duration
if
@section_duration
result
[
:section_options
]
=
@section_options
if
@section_options
end
end
end
end
end
end
...
...
lib/gitlab/ci/ansi2json/state.rb
View file @
dbb97bb9
...
@@ -26,10 +26,11 @@ module Gitlab
...
@@ -26,10 +26,11 @@ module Gitlab
Base64
.
urlsafe_encode64
(
state
.
to_json
)
Base64
.
urlsafe_encode64
(
state
.
to_json
)
end
end
def
open_section
(
section
,
timestamp
)
def
open_section
(
section
,
timestamp
,
options
)
@open_sections
[
section
]
=
timestamp
@open_sections
[
section
]
=
timestamp
@current_line
.
add_section
(
section
)
@current_line
.
add_section
(
section
)
@current_line
.
set_section_options
(
options
)
@current_line
.
set_as_section_header
@current_line
.
set_as_section_header
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