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
1500542c
Commit
1500542c
authored
Mar 08, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitlab.com/gitlab-org/gitlab-workhorse
parents
162424b9
74efa43f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
4 deletions
+13
-4
VERSION
VERSION
+1
-1
internal/git/blob.go
internal/git/blob.go
+9
-3
main_test.go
main_test.go
+3
-0
No files found.
VERSION
View file @
1500542c
v
0.7.0
0.7.0
internal/git/blob.go
View file @
1500542c
...
...
@@ -7,6 +7,7 @@ import (
"io"
"log"
"net/http"
"strings"
)
type
blob
struct
{
senddata
.
Prefix
}
...
...
@@ -23,10 +24,16 @@ func (b *blob) Inject(w http.ResponseWriter, r *http.Request, sendData string) {
log
.
Printf
(
"SendBlob: sending %q for %q"
,
params
.
BlobId
,
r
.
URL
.
Path
)
sizeOutput
,
err
:=
gitCommand
(
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"-s"
,
params
.
BlobId
)
.
Output
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendBlob: get blob size: %v"
,
err
))
return
}
gitShowCmd
:=
gitCommand
(
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"blob"
,
params
.
BlobId
)
stdout
,
err
:=
gitShowCmd
.
StdoutPipe
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendBlob: git stdout: %v"
,
err
))
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendBlob: git
cat-file
stdout: %v"
,
err
))
return
}
if
err
:=
gitShowCmd
.
Start
();
err
!=
nil
{
...
...
@@ -35,8 +42,7 @@ func (b *blob) Inject(w http.ResponseWriter, r *http.Request, sendData string) {
}
defer
helper
.
CleanUpProcessGroup
(
gitShowCmd
)
// Ignore incorrect Content-Length that may have been set by Rails
w
.
Header
()
.
Del
(
"Content-Length"
)
w
.
Header
()
.
Set
(
"Content-Length"
,
strings
.
TrimSpace
(
string
(
sizeOutput
)))
if
_
,
err
:=
io
.
Copy
(
w
,
stdout
);
err
!=
nil
{
helper
.
LogError
(
fmt
.
Errorf
(
"SendBlob: copy git cat-file stdout: %v"
,
err
))
return
...
...
main_test.go
View file @
1500542c
...
...
@@ -590,6 +590,9 @@ func TestGetGitBlob(t *testing.T) {
if
len
(
body
)
!=
blobLength
{
t
.
Fatalf
(
"Expected body of %d bytes, got %d"
,
blobLength
,
len
(
body
))
}
if
cl
:=
resp
.
Header
.
Get
(
"Content-Length"
);
cl
!=
fmt
.
Sprintf
(
"%d"
,
blobLength
)
{
t
.
Fatalf
(
"Expected Content-Length %v, got %q"
,
blobLength
,
cl
)
}
if
!
strings
.
HasPrefix
(
string
(
body
),
"The MIT License (MIT)"
)
{
t
.
Fatalf
(
"Expected MIT license, got %q"
,
body
)
}
...
...
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