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
27cc1c2b
Commit
27cc1c2b
authored
Oct 03, 2017
by
Andrew Newdigate
Committed by
Sean McGivern
Oct 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for Gitaly nil encoding issue
parent
d14230dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
2 deletions
+18
-2
lib/gitlab/gitaly_client.rb
lib/gitlab/gitaly_client.rb
+2
-0
lib/gitlab/gitaly_client/commit_service.rb
lib/gitlab/gitaly_client/commit_service.rb
+1
-1
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+1
-1
spec/lib/gitlab/gitaly_client_spec.rb
spec/lib/gitlab/gitaly_client_spec.rb
+14
-0
No files found.
lib/gitlab/gitaly_client.rb
View file @
27cc1c2b
...
@@ -233,6 +233,8 @@ module Gitlab
...
@@ -233,6 +233,8 @@ module Gitlab
end
end
def
self
.
encode
(
s
)
def
self
.
encode
(
s
)
return
""
if
s
.
nil?
s
.
dup
.
force_encoding
(
Encoding
::
ASCII_8BIT
)
s
.
dup
.
force_encoding
(
Encoding
::
ASCII_8BIT
)
end
end
...
...
lib/gitlab/gitaly_client/commit_service.rb
View file @
27cc1c2b
...
@@ -274,7 +274,7 @@ module Gitlab
...
@@ -274,7 +274,7 @@ module Gitlab
repository:
@gitaly_repo
,
repository:
@gitaly_repo
,
left_commit_id:
from_id
,
left_commit_id:
from_id
,
right_commit_id:
to_id
,
right_commit_id:
to_id
,
paths:
options
.
fetch
(
:paths
,
[]).
map
{
|
path
|
GitalyClient
.
encode
(
path
)
}
paths:
options
.
fetch
(
:paths
,
[]).
compact
.
map
{
|
path
|
GitalyClient
.
encode
(
path
)
}
}
}
end
end
...
...
spec/lib/gitlab/gitaly_client/commit_service_spec.rb
View file @
27cc1c2b
...
@@ -53,7 +53,7 @@ describe Gitlab::GitalyClient::CommitService do
...
@@ -53,7 +53,7 @@ describe Gitlab::GitalyClient::CommitService do
end
end
it
'encodes paths correctly'
do
it
'encodes paths correctly'
do
expect
{
client
.
diff_from_parent
(
commit
,
paths:
[
'encoding/test.txt'
,
'encoding/テスト.txt'
])
}.
not_to
raise_error
expect
{
client
.
diff_from_parent
(
commit
,
paths:
[
'encoding/test.txt'
,
'encoding/テスト.txt'
,
nil
])
}.
not_to
raise_error
end
end
end
end
...
...
spec/lib/gitlab/gitaly_client_spec.rb
View file @
27cc1c2b
...
@@ -38,6 +38,20 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
...
@@ -38,6 +38,20 @@ describe Gitlab::GitalyClient, skip_gitaly_mock: true do
end
end
end
end
describe
'encode'
do
[
[
nil
,
""
],
[
""
,
""
],
[
" "
,
" "
],
%w(a1 a1)
,
[
"编码"
,
"
\xE7\xBC\x96\xE7\xA0\x81
"
.
b
]
].
each
do
|
input
,
result
|
it
"encodes
#{
input
.
inspect
}
to
#{
result
.
inspect
}
"
do
expect
(
described_class
.
encode
(
input
)).
to
eq
result
end
end
end
describe
'allow_n_plus_1_calls'
do
describe
'allow_n_plus_1_calls'
do
context
'when RequestStore is enabled'
,
:request_store
do
context
'when RequestStore is enabled'
,
:request_store
do
it
'returns the result of the allow_n_plus_1_calls block'
do
it
'returns the result of the allow_n_plus_1_calls block'
do
...
...
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