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
d34481d1
Commit
d34481d1
authored
3 years ago
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use encoding constants instead of strings
This eliminates an extra lookup.
parent
f0d3c690
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
app/models/ci/build_trace_chunks/fog.rb
app/models/ci/build_trace_chunks/fog.rb
+2
-2
spec/models/ci/build_trace_chunks/fog_spec.rb
spec/models/ci/build_trace_chunks/fog_spec.rb
+9
-9
No files found.
app/models/ci/build_trace_chunks/fog.rb
View file @
d34481d1
...
...
@@ -82,9 +82,9 @@ module Ci
def
append_strings
(
old_data
,
new_data
)
if
Feature
.
enabled?
(
:ci_job_trace_force_encode
,
default_enabled: :yaml
)
# When object storage is in use, old_data may be retrieved in UTF-8.
old_data
=
old_data
.
force_encoding
(
'ASCII-8BIT'
)
old_data
=
old_data
.
force_encoding
(
Encoding
::
ASCII_8BIT
)
# new_data should already be in ASCII-8BIT, but just in case it isn't, do this.
new_data
=
new_data
.
force_encoding
(
'ASCII-8BIT'
)
new_data
=
new_data
.
force_encoding
(
Encoding
::
ASCII_8BIT
)
end
old_data
+
new_data
...
...
This diff is collapsed.
Click to expand it.
spec/models/ci/build_trace_chunks/fog_spec.rb
View file @
d34481d1
...
...
@@ -103,7 +103,7 @@ RSpec.describe Ci::BuildTraceChunks::Fog do
end
describe
'#append_data'
do
let
(
:initial_data
)
{
(
+
'😺'
).
force_encoding
(
'ASCII-8BIT'
)
}
let
(
:initial_data
)
{
(
+
'😺'
).
force_encoding
(
Encoding
::
ASCII_8BIT
)
}
let
(
:model
)
{
create
(
:ci_build_trace_chunk
,
:fog_with_data
,
initial_data:
initial_data
)
}
let
(
:data
)
{
data_store
.
data
(
model
)
}
...
...
@@ -111,15 +111,15 @@ RSpec.describe Ci::BuildTraceChunks::Fog do
it
'appends ASCII data'
do
data_store
.
append_data
(
model
,
+
'hello world'
,
4
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
.
find
(
'ASCII-8BIT'
)
)
expect
(
data
.
force_encoding
(
'UTF-8'
)).
to
eq
(
'😺hello world'
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
::
ASCII_8BIT
)
expect
(
data
.
force_encoding
(
Encoding
::
UTF_8
)).
to
eq
(
'😺hello world'
)
end
it
'appends UTF-8 data'
do
data_store
.
append_data
(
model
,
+
'Résumé'
,
4
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
.
find
(
'ASCII-8BIT'
)
)
expect
(
data
.
force_encoding
(
'UTF-8'
)).
to
eq
(
"😺Résumé"
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
::
ASCII_8BIT
)
expect
(
data
.
force_encoding
(
Encoding
::
UTF_8
)).
to
eq
(
"😺Résumé"
)
end
context
'when initial data is UTF-8'
do
...
...
@@ -128,8 +128,8 @@ RSpec.describe Ci::BuildTraceChunks::Fog do
it
'appends ASCII data'
do
data_store
.
append_data
(
model
,
+
'hello world'
,
4
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
.
find
(
'ASCII-8BIT'
)
)
expect
(
data
.
force_encoding
(
'UTF-8'
)).
to
eq
(
'😺hello world'
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
::
ASCII_8BIT
)
expect
(
data
.
force_encoding
(
Encoding
::
UTF_8
)).
to
eq
(
'😺hello world'
)
end
end
end
...
...
@@ -142,8 +142,8 @@ RSpec.describe Ci::BuildTraceChunks::Fog do
it
'appends ASCII data'
do
data_store
.
append_data
(
model
,
+
'hello world'
,
4
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
.
find
(
'ASCII-8BIT'
)
)
expect
(
data
.
force_encoding
(
'UTF-8'
)).
to
eq
(
'😺hello world'
)
expect
(
data
.
encoding
).
to
eq
(
Encoding
::
ASCII_8BIT
)
expect
(
data
.
force_encoding
(
Encoding
::
UTF_8
)).
to
eq
(
'😺hello world'
)
end
it
'throws an exception when appending UTF-8 data'
do
...
...
This diff is collapsed.
Click to expand it.
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