aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/client/ssh
diff options
context:
space:
mode:
authorferhat elmas <elmas.ferhat@gmail.com>2016-11-15 01:18:53 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-15 01:18:53 +0100
commit16d86605732ba3198c0acd4317b53cf4991a7d4d (patch)
tree3306f0438235f7dfe19fd37c5393a4794abe0535 /plumbing/client/ssh
parenteb89d2dd9a36440d58aea224c055b364e49785f7 (diff)
downloadgo-git-16d86605732ba3198c0acd4317b53cf4991a7d4d.tar.gz
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
Diffstat (limited to 'plumbing/client/ssh')
-rw-r--r--plumbing/client/ssh/git_upload_pack.go16
1 files changed, 6 insertions, 10 deletions
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)
}
}