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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
cf4ab10d
Commit
cf4ab10d
authored
May 24, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adopt ayufan script
parent
a1638748
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
lib/gitlab/ci/trace/stream.rb
lib/gitlab/ci/trace/stream.rb
+13
-12
No files found.
lib/gitlab/ci/trace/stream.rb
View file @
cf4ab10d
...
...
@@ -96,28 +96,29 @@ module Gitlab
end
def
reverse_line
return
if
stream
.
size
<=
0
pos
=
0
max
=
stream
.
size
stream
.
seek
(
0
,
IO
::
SEEK_END
)
debris
=
''
while
(
read_size
=
calc_read_size
(
pos
,
max
))
>
0
pos
+=
read_size
stream
.
seek
(
-
pos
,
IO
::
SEEK_END
)
buf
=
stream
.
read
(
read_size
)
+
debris
while
!
(
buf
=
read_backward
(
BUFFER_SIZE
)).
empty?
buf
+=
debris
debris
,
*
lines
=
buf
.
each_line
.
to_a
lines
.
reverse_each
do
|
line
|
yield
(
line
.
force_encoding
(
'UTF-8'
))
end
end
yield
(
debris
.
force_encoding
(
'UTF-8'
))
yield
(
debris
.
force_encoding
(
'UTF-8'
))
if
!
(
debris
).
empty?
end
def
calc_read_size
(
pos
,
max
)
remain
=
max
-
pos
(
remain
>
BUFFER_SIZE
)
?
BUFFER_SIZE
:
remain
def
read_backward
(
length
)
cur_offset
=
stream
.
tell
start
=
cur_offset
-
length
start
=
0
if
start
<
0
stream
.
seek
(
start
,
IO
::
SEEK_SET
)
stream
.
read
(
cur_offset
-
start
).
tap
do
stream
.
seek
(
start
,
IO
::
SEEK_SET
)
end
end
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