diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-25 15:10:40 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-08-25 15:10:40 +0200 |
commit | 0f97041639b55bc4631145e2053a47a1eb8cdef0 (patch) | |
tree | 07de52218d3c0e69994c2614f7875af2635ae682 /clients/ssh/git_upload_pack.go | |
parent | 0fa6f26b0e6ca242088794027c0a32d01e1bc6f9 (diff) | |
download | go-git-0f97041639b55bc4631145e2053a47a1eb8cdef0.tar.gz |
clients/http: better error handling
Diffstat (limited to 'clients/ssh/git_upload_pack.go')
-rw-r--r-- | clients/ssh/git_upload_pack.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clients/ssh/git_upload_pack.go b/clients/ssh/git_upload_pack.go index 03b289a..eb5926e 100644 --- a/clients/ssh/git_upload_pack.go +++ b/clients/ssh/git_upload_pack.go @@ -152,6 +152,7 @@ func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (rc io.Read if err != nil { return nil, err } + defer func() { // the session can be closed by the other endpoint, // therefore we must ignore a close error. @@ -168,20 +169,19 @@ func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (rc io.Read return nil, err } + if err := session.Start("git-upload-pack " + s.vcs.FullName + ".git"); err != nil { + return nil, err + } + go func() { fmt.Fprintln(si, r.String()) err = si.Close() }() - err = session.Start("git-upload-pack " + s.vcs.FullName + ".git") - if err != nil { - return nil, err - } // TODO: investigate this *ExitError type (command fails or // doesn't complete successfully), as it is happenning all // the time, but everything seems to work fine. - err = session.Wait() - if err != nil { + if err := session.Wait(); err != nil { if _, ok := err.(*ssh.ExitError); !ok { return nil, err } @@ -205,6 +205,7 @@ func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (rc io.Read if err != nil { return nil, err } + buf := bytes.NewBuffer(data) return ioutil.NopCloser(buf), nil } |