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
34a6f83d
Commit
34a6f83d
authored
Feb 11, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API
parent
771f14b9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
6 deletions
+29
-6
lib/api/repositories.rb
lib/api/repositories.rb
+1
-1
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+2
-2
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+10
-3
spec/support/workhorse_helpers.rb
spec/support/workhorse_helpers.rb
+16
-0
No files found.
lib/api/repositories.rb
View file @
34a6f83d
...
...
@@ -99,7 +99,7 @@ module API
begin
RepositoryArchiveCacheWorker
.
perform_async
header
*
Gitlab
::
Workhorse
.
send_git_archive
(
@project
,
params
[
:ref
],
params
[
:format
])
header
*
Gitlab
::
Workhorse
.
send_git_archive
(
user_project
,
params
[
:sha
],
params
[
:format
])
rescue
not_found!
(
'File'
)
end
...
...
lib/gitlab/workhorse.rb
View file @
34a6f83d
...
...
@@ -3,9 +3,9 @@ require 'json'
module
Gitlab
class
Workhorse
class
<<
self
SEND_DATA_HEADER
=
'Gitlab-Workhorse-Send-Data'
class
<<
self
def
send_git_blob
(
repository
,
blob
)
params
=
{
'RepoPath'
=>
repository
.
path_to_repo
,
...
...
spec/requests/api/repositories_spec.rb
View file @
34a6f83d
...
...
@@ -4,6 +4,7 @@ require 'mime/types'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
include
RepoHelpers
include
WorkhorseHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
...
...
@@ -91,21 +92,27 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/repository/archive"
,
user
)
repo_name
=
project
.
repository
.
name
.
gsub
(
"
\.
git"
,
""
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.tar.gz/
)
type
,
params
=
workhorse_send_data
expect
(
type
).
to
eq
(
'git-archive'
)
expect
(
params
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.tar.gz/
)
end
it
"should get the archive.zip"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/archive.zip"
,
user
)
repo_name
=
project
.
repository
.
name
.
gsub
(
"
\.
git"
,
""
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.zip/
)
type
,
params
=
workhorse_send_data
expect
(
type
).
to
eq
(
'git-archive'
)
expect
(
params
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.zip/
)
end
it
"should get the archive.tar.bz2"
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/archive.tar.bz2"
,
user
)
repo_name
=
project
.
repository
.
name
.
gsub
(
"
\.
git"
,
""
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.tar.bz2/
)
type
,
params
=
workhorse_send_data
expect
(
type
).
to
eq
(
'git-archive'
)
expect
(
params
[
'ArchivePath'
]).
to
match
(
/
#{
repo_name
}
\-[^\.]+\.tar.bz2/
)
end
it
"should return 404 for invalid sha"
do
...
...
spec/support/workhorse_helpers.rb
0 → 100644
View file @
34a6f83d
module
WorkhorseHelpers
extend
self
def
workhorse_send_data
@_workhorse_send_data
||=
begin
header
=
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]
split_header
=
header
.
split
(
':'
)
type
=
split_header
.
shift
header
=
split_header
.
join
(
':'
)
[
type
,
JSON
.
parse
(
Base64
.
urlsafe_decode64
(
header
)),
]
end
end
end
\ No newline at end of file
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