Commit 11677f52 authored by Nick Thomas's avatar Nick Thomas

Refactor gitCommand and gitCommandApi

parent 60fb872c
......@@ -74,7 +74,7 @@ func newArchiveReader(ctx context.Context, repoPath string, format ArchiveFormat
a = &archiveReader{}
compressCmd, formatArg := parseArchiveFormat(format)
archiveCmd := gitCommandApi(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
archiveStdout, err = archiveCmd.StdoutPipe()
......
......@@ -52,13 +52,13 @@ func handleSendBlobWithGitaly(w http.ResponseWriter, r *http.Request, params *bl
func handleSendBlobLocally(w http.ResponseWriter, r *http.Request, params *blobParams) {
log.Printf("SendBlob: sending %q for %q", params.BlobId, r.URL.Path)
sizeOutput, err := gitCommandApi(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 {
helper.Fail500(w, r, fmt.Errorf("SendBlob: get blob size: %v", err))
return
}
gitShowCmd := gitCommandApi(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()
if err != nil {
helper.Fail500(w, r, fmt.Errorf("SendBlob: git cat-file stdout: %v", err))
......
......@@ -33,3 +33,7 @@ func gitCommandApi(a *api.Response, name string, args ...string) *exec.Cmd {
cmd.Stderr = os.Stderr
return cmd
}
func gitCommand(name string, args ...string) *exec.Cmd {
return gitCommandApi(nil, name, args...)
}
......@@ -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)
gitDiffCmd := gitCommandApi(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()
if err != nil {
helper.Fail500(w, r, fmt.Errorf("SendDiff: create stdout pipe: %v", err))
......
......@@ -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)
gitRange := fmt.Sprintf("%s..%s", params.ShaFrom, params.ShaTo)
gitPatchCmd := gitCommandApi(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()
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment