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
11677f52
Commit
11677f52
authored
Sep 20, 2017
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor gitCommand and gitCommandApi
parent
60fb872c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
5 deletions
+9
-5
internal/git/archivereader.go
internal/git/archivereader.go
+1
-1
internal/git/blob.go
internal/git/blob.go
+2
-2
internal/git/command.go
internal/git/command.go
+4
-0
internal/git/diff.go
internal/git/diff.go
+1
-1
internal/git/format-patch.go
internal/git/format-patch.go
+1
-1
No files found.
internal/git/archivereader.go
View file @
11677f52
...
@@ -74,7 +74,7 @@ func newArchiveReader(ctx context.Context, repoPath string, format ArchiveFormat
...
@@ -74,7 +74,7 @@ func newArchiveReader(ctx context.Context, repoPath string, format ArchiveFormat
a
=
&
archiveReader
{}
a
=
&
archiveReader
{}
compressCmd
,
formatArg
:=
parseArchiveFormat
(
format
)
compressCmd
,
formatArg
:=
parseArchiveFormat
(
format
)
archiveCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
formatArg
,
"--prefix="
+
archivePrefix
+
"/"
,
commitId
)
archiveCmd
:=
gitCommand
(
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
formatArg
,
"--prefix="
+
archivePrefix
+
"/"
,
commitId
)
var
archiveStdout
io
.
ReadCloser
var
archiveStdout
io
.
ReadCloser
archiveStdout
,
err
=
archiveCmd
.
StdoutPipe
()
archiveStdout
,
err
=
archiveCmd
.
StdoutPipe
()
...
...
internal/git/blob.go
View file @
11677f52
...
@@ -52,13 +52,13 @@ func handleSendBlobWithGitaly(w http.ResponseWriter, r *http.Request, params *bl
...
@@ -52,13 +52,13 @@ func handleSendBlobWithGitaly(w http.ResponseWriter, r *http.Request, params *bl
func
handleSendBlobLocally
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
params
*
blobParams
)
{
func
handleSendBlobLocally
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
params
*
blobParams
)
{
log
.
Printf
(
"SendBlob: sending %q for %q"
,
params
.
BlobId
,
r
.
URL
.
Path
)
log
.
Printf
(
"SendBlob: sending %q for %q"
,
params
.
BlobId
,
r
.
URL
.
Path
)
sizeOutput
,
err
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"-s"
,
params
.
BlobId
)
.
Output
()
sizeOutput
,
err
:=
gitCommand
(
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"-s"
,
params
.
BlobId
)
.
Output
()
if
err
!=
nil
{
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: get blob size: %v"
,
err
))
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: get blob size: %v"
,
err
))
return
return
}
}
gitShowCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"blob"
,
params
.
BlobId
)
gitShowCmd
:=
gitCommand
(
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"blob"
,
params
.
BlobId
)
stdout
,
err
:=
gitShowCmd
.
StdoutPipe
()
stdout
,
err
:=
gitShowCmd
.
StdoutPipe
()
if
err
!=
nil
{
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: git cat-file stdout: %v"
,
err
))
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: git cat-file stdout: %v"
,
err
))
...
...
internal/git/command.go
View file @
11677f52
...
@@ -33,3 +33,7 @@ func gitCommandApi(a *api.Response, name string, args ...string) *exec.Cmd {
...
@@ -33,3 +33,7 @@ func gitCommandApi(a *api.Response, name string, args ...string) *exec.Cmd {
cmd
.
Stderr
=
os
.
Stderr
cmd
.
Stderr
=
os
.
Stderr
return
cmd
return
cmd
}
}
func
gitCommand
(
name
string
,
args
...
string
)
*
exec
.
Cmd
{
return
gitCommandApi
(
nil
,
name
,
args
...
)
}
internal/git/diff.go
View file @
11677f52
...
@@ -28,7 +28,7 @@ func (d *diff) Inject(w http.ResponseWriter, r *http.Request, sendData string) {
...
@@ -28,7 +28,7 @@ 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
)
log
.
Printf
(
"SendDiff: sending diff between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
gitDiffCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
gitDiffCmd
:=
gitCommand
(
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
stdout
,
err
:=
gitDiffCmd
.
StdoutPipe
()
stdout
,
err
:=
gitDiffCmd
.
StdoutPipe
()
if
err
!=
nil
{
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendDiff: create stdout pipe: %v"
,
err
))
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendDiff: create stdout pipe: %v"
,
err
))
...
...
internal/git/format-patch.go
View file @
11677f52
...
@@ -29,7 +29,7 @@ func (p *patch) Inject(w http.ResponseWriter, r *http.Request, sendData string)
...
@@ -29,7 +29,7 @@ func (p *patch) Inject(w http.ResponseWriter, r *http.Request, sendData string)
log
.
Printf
(
"SendPatch: sending patch between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
log
.
Printf
(
"SendPatch: sending patch between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
gitRange
:=
fmt
.
Sprintf
(
"%s..%s"
,
params
.
ShaFrom
,
params
.
ShaTo
)
gitRange
:=
fmt
.
Sprintf
(
"%s..%s"
,
params
.
ShaFrom
,
params
.
ShaTo
)
gitPatchCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"format-patch"
,
gitRange
,
"--stdout"
)
gitPatchCmd
:=
gitCommand
(
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"format-patch"
,
gitRange
,
"--stdout"
)
stdout
,
err
:=
gitPatchCmd
.
StdoutPipe
()
stdout
,
err
:=
gitPatchCmd
.
StdoutPipe
()
if
err
!=
nil
{
if
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