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
08ce213c
Commit
08ce213c
authored
Jul 10, 2017
by
Ahmad Sherif
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate Workhorse SendBlob to Gitaly
parent
64701b51
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
5 deletions
+61
-5
GITLAB_WORKHORSE_VERSION
GITLAB_WORKHORSE_VERSION
+1
-1
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+22
-4
spec/lib/gitlab/workhorse_spec.rb
spec/lib/gitlab/workhorse_spec.rb
+38
-0
No files found.
GITLAB_WORKHORSE_VERSION
View file @
08ce213c
2.3
.0
3.0
.0
lib/gitlab/workhorse.rb
View file @
08ce213c
...
@@ -62,10 +62,21 @@ module Gitlab
...
@@ -62,10 +62,21 @@ module Gitlab
end
end
def
send_git_blob
(
repository
,
blob
)
def
send_git_blob
(
repository
,
blob
)
params
=
{
params
=
if
Gitlab
::
GitalyClient
.
feature_enabled?
(
:project_raw_show
)
'RepoPath'
=>
repository
.
path_to_repo
,
{
'BlobId'
=>
blob
.
id
'GitalyServer'
=>
gitaly_server_hash
(
repository
),
}
'GetBlobRequest'
=>
{
repository:
repository
.
gitaly_repository
.
to_h
,
oid:
blob
.
id
,
limit:
-
1
}
}
else
{
'RepoPath'
=>
repository
.
path_to_repo
,
'BlobId'
=>
blob
.
id
}
end
[
[
SEND_DATA_HEADER
,
SEND_DATA_HEADER
,
...
@@ -192,6 +203,13 @@ module Gitlab
...
@@ -192,6 +203,13 @@ module Gitlab
def
encode
(
hash
)
def
encode
(
hash
)
Base64
.
urlsafe_encode64
(
JSON
.
dump
(
hash
))
Base64
.
urlsafe_encode64
(
JSON
.
dump
(
hash
))
end
end
def
gitaly_server_hash
(
repository
)
{
address:
Gitlab
::
GitalyClient
.
address
(
repository
.
project
.
repository_storage
),
token:
Gitlab
::
GitalyClient
.
token
(
repository
.
project
.
repository_storage
)
}
end
end
end
end
end
end
end
spec/lib/gitlab/workhorse_spec.rb
View file @
08ce213c
...
@@ -317,4 +317,42 @@ describe Gitlab::Workhorse, lib: true do
...
@@ -317,4 +317,42 @@ describe Gitlab::Workhorse, lib: true do
end
end
end
end
end
end
describe
'.send_git_blob'
do
include
FakeBlobHelpers
let
(
:blob
)
{
fake_blob
}
subject
{
described_class
.
send_git_blob
(
repository
,
blob
)
}
context
'when Gitaly project_raw_show feature is enabled'
do
it
'sets the header correctly'
do
key
,
command
,
params
=
decode_workhorse_header
(
subject
)
expect
(
key
).
to
eq
(
'Gitlab-Workhorse-Send-Data'
)
expect
(
command
).
to
eq
(
'git-blob'
)
expect
(
params
).
to
eq
({
'GitalyServer'
=>
{
address:
Gitlab
::
GitalyClient
.
address
(
project
.
repository_storage
),
token:
Gitlab
::
GitalyClient
.
token
(
project
.
repository_storage
)
},
'GetBlobRequest'
=>
{
repository:
repository
.
gitaly_repository
.
to_h
,
oid:
blob
.
id
,
limit:
-
1
}
}.
deep_stringify_keys
)
end
end
context
'when Gitaly project_raw_show feature is disabled'
,
skip_gitaly_mock:
true
do
it
'sets the header correctly'
do
key
,
command
,
params
=
decode_workhorse_header
(
subject
)
expect
(
key
).
to
eq
(
'Gitlab-Workhorse-Send-Data'
)
expect
(
command
).
to
eq
(
'git-blob'
)
expect
(
params
).
to
eq
(
'RepoPath'
=>
repository
.
path_to_repo
,
'BlobId'
=>
blob
.
id
)
end
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