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
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
iv
gitlab-workhorse
Commits
a89d639c
Commit
a89d639c
authored
Oct 10, 2015
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop passing repoPath around
parent
1fe3f55f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
githandler.go
githandler.go
+9
-10
No files found.
githandler.go
View file @
a89d639c
...
@@ -30,7 +30,7 @@ type gitHandler struct {
...
@@ -30,7 +30,7 @@ type gitHandler struct {
type
gitService
struct
{
type
gitService
struct
{
method
string
method
string
suffix
string
suffix
string
handleFunc
func
(
gitEnv
,
string
,
string
,
http
.
ResponseWriter
,
*
http
.
Request
)
handleFunc
func
(
gitEnv
,
string
,
http
.
ResponseWriter
,
*
http
.
Request
)
rpc
string
rpc
string
}
}
...
@@ -122,13 +122,12 @@ func (h *gitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
@@ -122,13 +122,12 @@ func (h *gitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
}
}
repoPath
:=
env
.
RepoPath
if
!
looksLikeRepo
(
env
.
RepoPath
)
{
if
!
looksLikeRepo
(
repoPath
)
{
http
.
Error
(
w
,
"Not Found"
,
404
)
http
.
Error
(
w
,
"Not Found"
,
404
)
return
return
}
}
g
.
handleFunc
(
env
,
g
.
rpc
,
repoPath
,
w
,
r
)
g
.
handleFunc
(
env
,
g
.
rpc
,
w
,
r
)
}
}
func
looksLikeRepo
(
p
string
)
bool
{
func
looksLikeRepo
(
p
string
)
bool
{
...
@@ -162,7 +161,7 @@ func (h *gitHandler) doAuthRequest(r *http.Request) (result *http.Response, err
...
@@ -162,7 +161,7 @@ func (h *gitHandler) doAuthRequest(r *http.Request) (result *http.Response, err
return
h
.
httpClient
.
Do
(
authReq
)
return
h
.
httpClient
.
Do
(
authReq
)
}
}
func
handleGetInfoRefs
(
env
gitEnv
,
_
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
handleGetInfoRefs
(
env
gitEnv
,
_
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
rpc
:=
r
.
URL
.
Query
()
.
Get
(
"service"
)
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
if
!
(
rpc
==
"git-upload-pack"
||
rpc
==
"git-receive-pack"
)
{
// The 'dumb' Git HTTP protocol is not supported
// The 'dumb' Git HTTP protocol is not supported
...
@@ -171,7 +170,7 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
...
@@ -171,7 +170,7 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
}
}
// Prepare our Git subprocess
// Prepare our Git subprocess
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
r
epoPath
)
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
"--advertise-refs"
,
env
.
R
epoPath
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"handleGetInfoRefs"
,
err
)
fail500
(
w
,
"handleGetInfoRefs"
,
err
)
...
@@ -206,7 +205,7 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
...
@@ -206,7 +205,7 @@ func handleGetInfoRefs(env gitEnv, _ string, repoPath string, w http.ResponseWri
}
}
}
}
func
handleGetArchive
(
env
gitEnv
,
format
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
handleGetArchive
(
env
gitEnv
,
format
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
archiveFilename
:=
path
.
Base
(
env
.
ArchivePath
)
archiveFilename
:=
path
.
Base
(
env
.
ArchivePath
)
if
cachedArchive
,
err
:=
os
.
Open
(
env
.
ArchivePath
);
err
==
nil
{
if
cachedArchive
,
err
:=
os
.
Open
(
env
.
ArchivePath
);
err
==
nil
{
...
@@ -234,7 +233,7 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
...
@@ -234,7 +233,7 @@ func handleGetArchive(env gitEnv, format string, repoPath string, w http.Respons
compressCmd
,
archiveFormat
:=
parseArchiveFormat
(
format
)
compressCmd
,
archiveFormat
:=
parseArchiveFormat
(
format
)
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
r
epoPath
,
"archive"
,
"--format="
+
archiveFormat
,
"--prefix="
+
env
.
ArchivePrefix
+
"/"
,
env
.
CommitId
)
archiveCmd
:=
gitCommand
(
env
,
"git"
,
"--git-dir="
+
env
.
R
epoPath
,
"archive"
,
"--format="
+
archiveFormat
,
"--prefix="
+
env
.
ArchivePrefix
+
"/"
,
env
.
CommitId
)
archiveStdout
,
err
:=
archiveCmd
.
StdoutPipe
()
archiveStdout
,
err
:=
archiveCmd
.
StdoutPipe
()
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"handleGetArchive"
,
err
)
fail500
(
w
,
"handleGetArchive"
,
err
)
...
@@ -335,7 +334,7 @@ func finalizeCachedArchive(tempFile *os.File, archivePath string) error {
...
@@ -335,7 +334,7 @@ func finalizeCachedArchive(tempFile *os.File, archivePath string) error {
return
os
.
Link
(
tempFile
.
Name
(),
archivePath
)
return
os
.
Link
(
tempFile
.
Name
(),
archivePath
)
}
}
func
handlePostRPC
(
env
gitEnv
,
rpc
string
,
repoPath
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
handlePostRPC
(
env
gitEnv
,
rpc
string
,
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
body
io
.
ReadCloser
var
body
io
.
ReadCloser
var
err
error
var
err
error
...
@@ -352,7 +351,7 @@ func handlePostRPC(env gitEnv, rpc string, repoPath string, w http.ResponseWrite
...
@@ -352,7 +351,7 @@ func handlePostRPC(env gitEnv, rpc string, repoPath string, w http.ResponseWrite
defer
body
.
Close
()
defer
body
.
Close
()
// Prepare our Git subprocess
// Prepare our Git subprocess
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
r
epoPath
)
cmd
:=
gitCommand
(
env
,
"git"
,
subCommand
(
rpc
),
"--stateless-rpc"
,
env
.
R
epoPath
)
stdout
,
err
:=
cmd
.
StdoutPipe
()
stdout
,
err
:=
cmd
.
StdoutPipe
()
if
err
!=
nil
{
if
err
!=
nil
{
fail500
(
w
,
"handlePostRPC"
,
err
)
fail500
(
w
,
"handlePostRPC"
,
err
)
...
...
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