From 16d86605732ba3198c0acd4317b53cf4991a7d4d Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Tue, 15 Nov 2016 01:18:53 +0100 Subject: Add configurable http client factory (fixes #120) (#121) * new http client factory ready to install/override default http(s) * mv GitUploadPackServiceFactory to clients.common pkg * rename http.HTTPError to http.Err * rename http.HTTPAuthMethod to http.AuthMethod * add doc and examples/ usage * general improvements: - update install link in readme to v4 (example are already pointing v4) - fix indentation in package doc (styling for godoc.org) - use http.Status constants instead of integers - close leaked response body - rm named returns which stutter in doc - fix one format string - rm unnecessary if checks - documentation fixes --- plumbing/client/ssh/git_upload_pack.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'plumbing/client/ssh') diff --git a/plumbing/client/ssh/git_upload_pack.go b/plumbing/client/ssh/git_upload_pack.go index e2b73fd..db7fa93 100644 --- a/plumbing/client/ssh/git_upload_pack.go +++ b/plumbing/client/ssh/git_upload_pack.go @@ -84,11 +84,7 @@ func (s *GitUploadPackService) setAuthFromEndpoint() error { var err error s.auth, err = NewSSHAgentAuth(u) - if err != nil { - return err - } - - return nil + return err } // SetAuth sets the AuthMethod @@ -105,7 +101,7 @@ func (s *GitUploadPackService) SetAuth(auth common.AuthMethod) error { // Info returns the GitUploadPackInfo of the repository. The client must be // connected with the repository (using the ConnectWithAuth() method) before // using this method. -func (s *GitUploadPackService) Info() (i *common.GitUploadPackInfo, err error) { +func (s *GitUploadPackService) Info() (*common.GitUploadPackInfo, error) { if !s.connected { return nil, ErrNotConnected } @@ -125,12 +121,12 @@ func (s *GitUploadPackService) Info() (i *common.GitUploadPackInfo, err error) { return nil, err } - i = common.NewGitUploadPackInfo() + i := common.NewGitUploadPackInfo() return i, i.Decode(bytes.NewReader(out)) } // Disconnect the SSH client. -func (s *GitUploadPackService) Disconnect() (err error) { +func (s *GitUploadPackService) Disconnect() error { if !s.connected { return ErrNotConnected } @@ -142,7 +138,7 @@ func (s *GitUploadPackService) Disconnect() (err error) { // SSH session on a connected GitUploadPackService, sends the given // upload request to the server and returns a reader for the received // packfile. Closing the returned reader will close the SSH session. -func (s *GitUploadPackService) Fetch(req *common.GitUploadPackRequest) (rc io.ReadCloser, err error) { +func (s *GitUploadPackService) Fetch(req *common.GitUploadPackRequest) (io.ReadCloser, error) { if !s.connected { return nil, ErrNotConnected } @@ -243,7 +239,7 @@ func sendHaves(w io.Writer, req *common.GitUploadPackRequest) error { e := pktline.NewEncoder(w) for _, have := range req.Haves { if err := e.Encodef("have %s\n", have); err != nil { - return fmt.Errorf("sending haves for %q: err ", have, err) + return fmt.Errorf("sending haves for %q: %s", have, err) } } -- cgit