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
Jérome Perrin
gitlab-ce
Commits
fce708c1
Commit
fce708c1
authored
Sep 30, 2017
by
Alejandro Rodríguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send extra Gitaly params for `send_git_archive` if needed
parent
b40192a9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+7
-0
spec/lib/gitlab/workhorse_spec.rb
spec/lib/gitlab/workhorse_spec.rb
+39
-1
No files found.
lib/gitlab/workhorse.rb
View file @
fce708c1
...
...
@@ -89,6 +89,13 @@ module Gitlab
params
=
repository
.
archive_metadata
(
ref
,
Gitlab
.
config
.
gitlab
.
repository_downloads_path
,
format
)
raise
"Repository or ref not found"
if
params
.
empty?
if
Gitlab
::
GitalyClient
.
feature_enabled?
(
:workhorse_archive
)
params
.
merge!
(
'GitalyServer'
=>
gitaly_server_hash
(
repository
),
'GitalyRepository'
=>
repository
.
gitaly_repository
.
to_h
)
end
[
SEND_DATA_HEADER
,
"git-archive:
#{
encode
(
params
)
}
"
...
...
spec/lib/gitlab/workhorse_spec.rb
View file @
fce708c1
...
...
@@ -13,13 +13,51 @@ describe Gitlab::Workhorse do
end
describe
".send_git_archive"
do
let
(
:ref
)
{
'master'
}
let
(
:format
)
{
'zip'
}
let
(
:storage_path
)
{
Gitlab
.
config
.
gitlab
.
repository_downloads_path
}
let
(
:base_params
)
{
repository
.
archive_metadata
(
ref
,
storage_path
,
format
)
}
let
(
:gitaly_params
)
do
base_params
.
merge
(
'GitalyServer'
=>
{
'address'
=>
Gitlab
::
GitalyClient
.
address
(
project
.
repository_storage
),
'token'
=>
Gitlab
::
GitalyClient
.
token
(
project
.
repository_storage
)
},
'GitalyRepository'
=>
repository
.
gitaly_repository
.
to_h
.
deep_stringify_keys
)
end
subject
do
described_class
.
send_git_archive
(
repository
,
ref:
ref
,
format:
format
)
end
context
'when Gitaly workhorse_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-archive'
)
expect
(
params
).
to
include
(
gitaly_params
)
end
end
context
'when Gitaly workhorse_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-archive'
)
expect
(
params
).
to
eq
(
base_params
)
end
end
context
"when the repository doesn't have an archive file path"
do
before
do
allow
(
project
.
repository
).
to
receive
(
:archive_metadata
).
and_return
(
Hash
.
new
)
end
it
"raises an error"
do
expect
{
described_class
.
send_git_archive
(
project
.
repository
,
ref:
"master"
,
format:
"zip"
)
}.
to
raise_error
(
RuntimeError
)
expect
{
subject
}.
to
raise_error
(
RuntimeError
)
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