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
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-workhorse
Commits
103750f1
Commit
103750f1
authored
Oct 07, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass ArchivePrefix from authBackend
parent
4d645003
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
githandler.go
githandler.go
+7
-7
main_test.go
main_test.go
+12
-1
No files found.
githandler.go
View file @
103750f1
...
...
@@ -33,10 +33,11 @@ type gitService struct {
}
type
gitEnv
struct
{
GL_ID
string
RepoPath
string
ArchivePath
string
CommitId
string
GL_ID
string
RepoPath
string
ArchivePath
string
ArchivePrefix
string
CommitId
string
}
// Routing table
...
...
@@ -113,7 +114,7 @@ func (h *gitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Negotiate authentication (Kerberos) may need to return a WWW-Authenticate
// header to the client even in case of success as per RFC4559.
for
k
,
v
:=
range
authResponse
.
Header
{
// Case-insensitive comparison as per RFC7230
// Case-insensitive comparison as per RFC7230
if
strings
.
EqualFold
(
k
,
"WWW-Authenticate"
)
{
w
.
Header
()[
k
]
=
v
}
...
...
@@ -222,9 +223,8 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
}
archiveFilename
:=
path
.
Base
(
env
.
ArchivePath
)
archivePrefix
:=
strings
.
TrimSuffix
(
archiveFilename
,
"."
+
format
)
+
"/"
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
archiveFormat
,
"--prefix="
+
archivePrefix
,
env
.
CommitId
)
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
archiveFormat
,
"--prefix="
+
env
.
ArchivePrefix
+
"/"
,
env
.
CommitId
)
archiveStdout
,
err
:=
archiveCmd
.
StdoutPipe
()
if
err
!=
nil
{
fail500
(
w
,
"handleGetArchive"
,
err
)
...
...
main_test.go
View file @
103750f1
...
...
@@ -260,7 +260,18 @@ func gitOkBody(t *testing.T) string {
}
func
archiveOkBody
(
t
*
testing
.
T
,
archiveName
string
)
string
{
return
fmt
.
Sprintf
(
`{"RepoPath":"%s","ArchivePath":"/tmp/%s","CommitId":"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd"}`
,
repoPath
(
t
),
archiveName
)
cwd
,
err
:=
os
.
Getwd
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
archivePath
:=
path
.
Join
(
cwd
,
scratchDir
,
"cache"
,
archiveName
)
jsonString
:=
`{
"RepoPath":"%s",
"ArchivePath":"/tmp/%s",
"CommitId":"c7fbe50c7c7419d9701eebe64b1fdacc3df5b9dd",
"ArchivePrefix":"foobar123"
}`
return
fmt
.
Sprintf
(
jsonString
,
repoPath
(
t
),
archivePath
)
}
func
repoPath
(
t
*
testing
.
T
)
string
{
...
...
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