aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/ssh/common.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-05-04 10:17:15 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2017-05-04 10:17:15 +0200
commitb8b61e74469e0d2662e7d690eee14893f91fe259 (patch)
tree1933fe53200d98ad2c557d034609408641ce2900 /plumbing/transport/ssh/common.go
parent40fa5882a2c73f8c075403b7ec85870f04deda07 (diff)
parente80cdbabb92a1ec35ffad536f52d3ff04b548fd1 (diff)
downloadgo-git-b8b61e74469e0d2662e7d690eee14893f91fe259.tar.gz
Merge branch 'master' of github.com:src-d/go-git into commit
Diffstat (limited to 'plumbing/transport/ssh/common.go')
-rw-r--r--plumbing/transport/ssh/common.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/plumbing/transport/ssh/common.go b/plumbing/transport/ssh/common.go
index 7b44a91..d53fc12 100644
--- a/plumbing/transport/ssh/common.go
+++ b/plumbing/transport/ssh/common.go
@@ -3,7 +3,6 @@ package ssh
import (
"fmt"
- "strings"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/plumbing/transport/internal/common"
@@ -20,6 +19,8 @@ var DefaultAuthBuilder = func(user string) (AuthMethod, error) {
return NewSSHAgentAuth(user)
}
+const DefaultPort = 22
+
type runner struct{}
func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
@@ -110,25 +111,21 @@ func (c *command) connect() error {
}
func (c *command) getHostWithPort() string {
- host := c.endpoint.Host
- if strings.Index(c.endpoint.Host, ":") == -1 {
- host += ":22"
+ host := c.endpoint.Host()
+ port := c.endpoint.Port()
+ if port <= 0 {
+ port = DefaultPort
}
- return host
+ return fmt.Sprintf("%s:%d", host, port)
}
func (c *command) setAuthFromEndpoint() error {
- var u string
- if info := c.endpoint.User; info != nil {
- u = info.Username()
- }
-
var err error
- c.auth, err = DefaultAuthBuilder(u)
+ c.auth, err = DefaultAuthBuilder(c.endpoint.User())
return err
}
func endpointToCommand(cmd string, ep transport.Endpoint) string {
- return fmt.Sprintf("%s '%s'", cmd, ep.Path)
+ return fmt.Sprintf("%s '%s'", cmd, ep.Path())
}