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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
370dbd63
Commit
370dbd63
authored
Oct 04, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get CommitId and ArchivePrefix from upstream
parent
703ce004
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
githandler.go
githandler.go
+6
-7
No files found.
githandler.go
View file @
370dbd63
...
...
@@ -36,6 +36,7 @@ type gitEnv struct {
GL_ID
string
RepoPath
string
ArchivePath
string
CommitId
string
}
// Routing table
...
...
@@ -187,11 +188,6 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
}
func
handleGetArchive
(
env
gitEnv
,
format
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
ref
:=
r
.
URL
.
Query
()
.
Get
(
"ref"
)
if
ref
==
""
{
ref
=
"HEAD"
}
var
compressCmd
*
exec
.
Cmd
var
archiveFormat
string
switch
format
{
...
...
@@ -209,7 +205,10 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
compressCmd
=
nil
}
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
archiveFormat
,
ref
)
archiveFilename
:=
path
.
Base
(
env
.
ArchivePath
)
archivePrefix
:=
strings
.
TrimSuffix
(
archiveFilename
,
"."
+
format
)
+
"/"
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
archiveFormat
,
"--prefix="
+
archivePrefix
,
env
.
CommitId
)
archiveStdout
,
err
:=
archiveCmd
.
StdoutPipe
()
if
err
!=
nil
{
fail500
(
w
,
"handleGetArchive"
,
err
)
...
...
@@ -251,7 +250,7 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
w
.
Header
()
.
Add
(
"Content-Type"
,
"application/octet-stream"
)
}
w
.
Header
()
.
Add
(
"Content-Transfer-Encoding"
,
"binary"
)
w
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
`attachment; filename="%s"`
,
path
.
Base
(
env
.
ArchivePath
)
))
w
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
`attachment; filename="%s"`
,
archiveFilename
))
w
.
Header
()
.
Add
(
"Cache-Control"
,
"private"
)
w
.
WriteHeader
(
200
)
// Don't bother with HTTP 500 from this point on, just return
if
_
,
err
:=
io
.
Copy
(
w
,
stdout
);
err
!=
nil
{
...
...
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