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
6f92a907
Commit
6f92a907
authored
May 30, 2016
by
ZJ van de Weg
Committed by
Z.J. van de Weg
Jun 03, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Incorporate feedback
parent
e520eb91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
internal/git/diff.go
internal/git/diff.go
+11
-9
main_test.go
main_test.go
+7
-2
No files found.
internal/git/diff.go
View file @
6f92a907
...
...
@@ -28,24 +28,26 @@ func (d *diff) Inject(w http.ResponseWriter, r *http.Request, sendData string) {
log
.
Printf
(
"SendDiff: sending diff between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
git
Show
Cmd
:=
gitCommand
(
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
stdout
,
err
:=
git
Show
Cmd
.
StdoutPipe
()
git
Diff
Cmd
:=
gitCommand
(
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
stdout
,
err
:=
git
Diff
Cmd
.
StdoutPipe
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendDiff:
git diff %q %q stdout: %v"
,
params
.
ShaFrom
,
params
.
ShaTo
,
err
))
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendDiff:
create stdout pipe: %v"
,
err
))
return
}
if
err
:=
gitShowCmd
.
Start
();
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendDiff: git diff %q %q stdout: %v"
,
params
.
ShaFrom
,
params
.
ShaTo
,
err
))
if
err
:=
gitDiffCmd
.
Start
();
err
!=
nil
{
helper
.
Fail500
(
w
,
fmt
.
Errorf
(
"SendDiff: start %v: %v"
,
gitDiffCmd
,
err
))
return
}
defer
helper
.
CleanUpProcessGroup
(
git
Show
Cmd
)
defer
helper
.
CleanUpProcessGroup
(
git
Diff
Cmd
)
w
.
Header
()
.
Del
(
"Content-Length"
)
if
_
,
err
:=
io
.
Copy
(
w
,
stdout
);
err
!=
nil
{
helper
.
LogError
(
fmt
.
Errorf
(
"SendDiff:
git diff %q %q stdout: %v"
,
err
))
helper
.
LogError
(
fmt
.
Errorf
(
"SendDiff:
copy %v stdout: %v"
,
gitDiffCmd
,
err
))
return
}
if
err
:=
git
Show
Cmd
.
Wait
();
err
!=
nil
{
helper
.
LogError
(
fmt
.
Errorf
(
"SendDiff:
git diff %q %q stdout: %v"
,
err
))
if
err
:=
git
Diff
Cmd
.
Wait
();
err
!=
nil
{
helper
.
LogError
(
fmt
.
Errorf
(
"SendDiff:
wait for %v: %v"
,
gitDiffCmd
,
err
))
return
}
}
main_test.go
View file @
6f92a907
...
...
@@ -610,10 +610,10 @@ func TestGetGitDiff(t *testing.T) {
w
.
Header
()
.
Set
(
headerKey
,
"git-diff:"
+
encodedJSON
)
return
})
defer
ts
.
Close
()
ws
:=
startWorkhorseServer
(
ts
.
URL
)
defer
t
s
.
Close
()
defer
w
s
.
Close
()
resourcePath
:=
"/something"
resp
,
err
:=
http
.
Get
(
ws
.
URL
+
resourcePath
)
...
...
@@ -636,6 +636,11 @@ func TestGetGitDiff(t *testing.T) {
if
!
strings
.
HasPrefix
(
string
(
body
),
"diff --git a/README b/README"
)
{
t
.
Fatalf
(
"diff --git a/README b/README, got %q"
,
body
)
}
bodyLengthBytes
:=
len
(
body
)
if
bodyLengthBytes
!=
155
{
t
.
Fatal
(
"Expected the body to consist of 155 bytes, got %v"
,
bodyLengthBytes
)
}
}
func
setupStaticFile
(
fpath
,
content
string
)
error
{
...
...
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