Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-workhorse
Commits
5420af88
Commit
5420af88
authored
Aug 05, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for archive.tar.xz
( will send upstream after testing whether it works )
parent
d23a3247
Pipeline
#1190
failed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
internal/git/archive.go
internal/git/archive.go
+4
-0
main_test.go
main_test.go
+19
-0
No files found.
internal/git/archive.go
View file @
5420af88
...
@@ -48,6 +48,8 @@ func (a *archive) Inject(w http.ResponseWriter, r *http.Request, sendData string
...
@@ -48,6 +48,8 @@ func (a *archive) Inject(w http.ResponseWriter, r *http.Request, sendData string
format
=
"tar.gz"
format
=
"tar.gz"
case
"archive.tar.bz2"
:
case
"archive.tar.bz2"
:
format
=
"tar.bz2"
format
=
"tar.bz2"
case
"archive.tar.xz"
:
format
=
"tar.xz"
default
:
default
:
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"handleGetArchive: invalid format: %s"
,
urlPath
))
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"handleGetArchive: invalid format: %s"
,
urlPath
))
return
return
...
@@ -163,6 +165,8 @@ func parseArchiveFormat(format string) (*exec.Cmd, string) {
...
@@ -163,6 +165,8 @@ func parseArchiveFormat(format string) (*exec.Cmd, string) {
return
exec
.
Command
(
"gzip"
,
"-c"
,
"-n"
),
"tar"
return
exec
.
Command
(
"gzip"
,
"-c"
,
"-n"
),
"tar"
case
"tar.bz2"
:
case
"tar.bz2"
:
return
exec
.
Command
(
"bzip2"
,
"-c"
),
"tar"
return
exec
.
Command
(
"bzip2"
,
"-c"
),
"tar"
case
"tar.xz"
:
return
exec
.
Command
(
"xz"
,
"-c"
),
"tar"
case
"zip"
:
case
"zip"
:
return
nil
,
"zip"
return
nil
,
"zip"
}
}
...
...
main_test.go
View file @
5420af88
...
@@ -189,6 +189,25 @@ func TestAllowedDownloadTarBz2(t *testing.T) {
...
@@ -189,6 +189,25 @@ func TestAllowedDownloadTarBz2(t *testing.T) {
runOrFail
(
t
,
extractCmd
)
runOrFail
(
t
,
extractCmd
)
}
}
func
TestAllowedDownloadTarXz
(
t
*
testing
.
T
)
{
prepareDownloadDir
(
t
)
// Prepare test server and backend
archiveName
:=
"foobar.tar.xz"
ts
:=
archiveOKServer
(
t
,
archiveName
)
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
ws
.
Close
()
downloadCmd
:=
exec
.
Command
(
"curl"
,
"-J"
,
"-O"
,
fmt
.
Sprintf
(
"%s/%s/repository/archive.tar.xz"
,
ws
.
URL
,
testProject
))
downloadCmd
.
Dir
=
scratchDir
runOrFail
(
t
,
downloadCmd
)
extractCmd
:=
exec
.
Command
(
"tar"
,
"Jxf"
,
archiveName
)
extractCmd
.
Dir
=
scratchDir
runOrFail
(
t
,
extractCmd
)
}
func
TestAllowedApiDownloadZip
(
t
*
testing
.
T
)
{
func
TestAllowedApiDownloadZip
(
t
*
testing
.
T
)
{
prepareDownloadDir
(
t
)
prepareDownloadDir
(
t
)
...
...
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