aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-11-21 08:43:11 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-11-21 08:43:11 +0100
commit5eb1c562e7deb4191cb160af91a864fb783c1041 (patch)
tree090b3fef25c728381f384f9e04a86fa9905549c8 /plumbing/transport
parent90796406c0755f61761fb176cdfe6106f00d903c (diff)
downloadgo-git-5eb1c562e7deb4191cb160af91a864fb783c1041.tar.gz
*: add pointer to the new transport.Endpoint struct
Signed-off-by: Máximo Cuadros <mcuadros@gmail.com>
Diffstat (limited to 'plumbing/transport')
-rw-r--r--plumbing/transport/client/client.go8
-rw-r--r--plumbing/transport/client/client_test.go4
-rw-r--r--plumbing/transport/file/client.go4
-rw-r--r--plumbing/transport/file/client_test.go2
-rw-r--r--plumbing/transport/git/common.go18
-rw-r--r--plumbing/transport/git/common_test.go4
-rw-r--r--plumbing/transport/http/common.go16
-rw-r--r--plumbing/transport/http/common_test.go6
-rw-r--r--plumbing/transport/http/receive_pack.go4
-rw-r--r--plumbing/transport/http/upload_pack.go5
-rw-r--r--plumbing/transport/http/upload_pack_test.go4
-rw-r--r--plumbing/transport/internal/common/common.go8
-rw-r--r--plumbing/transport/server/loader.go8
-rw-r--r--plumbing/transport/server/loader_test.go2
-rw-r--r--plumbing/transport/server/receive_pack_test.go4
-rw-r--r--plumbing/transport/server/server.go4
-rw-r--r--plumbing/transport/server/server_test.go27
-rw-r--r--plumbing/transport/server/upload_pack_test.go17
-rw-r--r--plumbing/transport/ssh/common.go14
-rw-r--r--plumbing/transport/ssh/upload_pack_test.go4
-rw-r--r--plumbing/transport/test/receive_pack.go14
-rw-r--r--plumbing/transport/test/upload_pack.go6
22 files changed, 82 insertions, 101 deletions
diff --git a/plumbing/transport/client/client.go b/plumbing/transport/client/client.go
index 76c1469..90635a5 100644
--- a/plumbing/transport/client/client.go
+++ b/plumbing/transport/client/client.go
@@ -34,14 +34,14 @@ func InstallProtocol(scheme string, c transport.Transport) {
// NewClient returns the appropriate client among of the set of known protocols:
// http://, https://, ssh:// and file://.
// See `InstallProtocol` to add or modify protocols.
-func NewClient(endpoint transport.Endpoint) (transport.Transport, error) {
- f, ok := Protocols[endpoint.Protocol()]
+func NewClient(endpoint *transport.Endpoint) (transport.Transport, error) {
+ f, ok := Protocols[endpoint.Protocol]
if !ok {
- return nil, fmt.Errorf("unsupported scheme %q", endpoint.Protocol())
+ return nil, fmt.Errorf("unsupported scheme %q", endpoint.Protocol)
}
if f == nil {
- return nil, fmt.Errorf("malformed client for scheme %q, client is defined as nil", endpoint.Protocol())
+ return nil, fmt.Errorf("malformed client for scheme %q, client is defined as nil", endpoint.Protocol)
}
return f, nil
diff --git a/plumbing/transport/client/client_test.go b/plumbing/transport/client/client_test.go
index 2b686b6..65cf574 100644
--- a/plumbing/transport/client/client_test.go
+++ b/plumbing/transport/client/client_test.go
@@ -59,12 +59,12 @@ type dummyClient struct {
*http.Client
}
-func (*dummyClient) NewUploadPackSession(transport.Endpoint, transport.AuthMethod) (
+func (*dummyClient) NewUploadPackSession(*transport.Endpoint, transport.AuthMethod) (
transport.UploadPackSession, error) {
return nil, nil
}
-func (*dummyClient) NewReceivePackSession(transport.Endpoint, transport.AuthMethod) (
+func (*dummyClient) NewReceivePackSession(*transport.Endpoint, transport.AuthMethod) (
transport.ReceivePackSession, error) {
return nil, nil
}
diff --git a/plumbing/transport/file/client.go b/plumbing/transport/file/client.go
index d229fdd..e799ee1 100644
--- a/plumbing/transport/file/client.go
+++ b/plumbing/transport/file/client.go
@@ -73,7 +73,7 @@ func prefixExecPath(cmd string) (string, error) {
return cmd, nil
}
-func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod,
+func (r *runner) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod,
) (common.Command, error) {
switch cmd {
@@ -95,7 +95,7 @@ func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthM
}
}
- return &command{cmd: exec.Command(cmd, ep.Path())}, nil
+ return &command{cmd: exec.Command(cmd, ep.Path)}, nil
}
type command struct {
diff --git a/plumbing/transport/file/client_test.go b/plumbing/transport/file/client_test.go
index 864cddc..25ea278 100644
--- a/plumbing/transport/file/client_test.go
+++ b/plumbing/transport/file/client_test.go
@@ -41,7 +41,7 @@ repositoryformatversion = 0
filemode = true
bare = true`
-func prepareRepo(c *C, path string) transport.Endpoint {
+func prepareRepo(c *C, path string) *transport.Endpoint {
ep, err := transport.NewEndpoint(path)
c.Assert(err, IsNil)
diff --git a/plumbing/transport/git/common.go b/plumbing/transport/git/common.go
index fcd02f8..78aaa3b 100644
--- a/plumbing/transport/git/common.go
+++ b/plumbing/transport/git/common.go
@@ -20,7 +20,7 @@ const DefaultPort = 9418
type runner struct{}
// Command returns a new Command for the given cmd in the given Endpoint
-func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
+func (r *runner) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
// auth not allowed since git protocol doesn't support authentication
if auth != nil {
return nil, transport.ErrInvalidAuthMethod
@@ -36,7 +36,7 @@ type command struct {
conn net.Conn
connected bool
command string
- endpoint transport.Endpoint
+ endpoint *transport.Endpoint
}
// Start executes the command sending the required message to the TCP connection
@@ -63,8 +63,8 @@ func (c *command) connect() error {
}
func (c *command) getHostWithPort() string {
- host := c.endpoint.Host()
- port := c.endpoint.Port()
+ host := c.endpoint.Host
+ port := c.endpoint.Port
if port <= 0 {
port = DefaultPort
}
@@ -89,13 +89,13 @@ func (c *command) StdoutPipe() (io.Reader, error) {
return c.conn, nil
}
-func endpointToCommand(cmd string, ep transport.Endpoint) string {
- host := ep.Host()
- if ep.Port() != DefaultPort {
- host = fmt.Sprintf("%s:%d", ep.Host(), ep.Port())
+func endpointToCommand(cmd string, ep *transport.Endpoint) string {
+ host := ep.Host
+ if ep.Port != DefaultPort {
+ host = fmt.Sprintf("%s:%d", ep.Host, ep.Port)
}
- return fmt.Sprintf("%s %s%chost=%s%c", cmd, ep.Path(), 0, host, 0)
+ return fmt.Sprintf("%s %s%chost=%s%c", cmd, ep.Path, 0, host, 0)
}
// Close closes the TCP connection and connection.
diff --git a/plumbing/transport/git/common_test.go b/plumbing/transport/git/common_test.go
index 9f54fdc..bdc326f 100644
--- a/plumbing/transport/git/common_test.go
+++ b/plumbing/transport/git/common_test.go
@@ -64,14 +64,14 @@ func (s *BaseSuite) StartDaemon(c *C) {
time.Sleep(time.Millisecond * 500)
}
-func (s *BaseSuite) newEndpoint(c *C, name string) transport.Endpoint {
+func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint {
ep, err := transport.NewEndpoint(fmt.Sprintf("git://localhost:%d/%s", s.port, name))
c.Assert(err, IsNil)
return ep
}
-func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint {
+func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint {
fs := f.DotGit()
err := fixtures.EnsureIsBare(fs)
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go
index 6b40d42..95103f7 100644
--- a/plumbing/transport/http/common.go
+++ b/plumbing/transport/http/common.go
@@ -39,7 +39,7 @@ func advertisedReferences(s *session, serviceName string) (*packp.AdvRefs, error
}
s.applyAuthToRequest(req)
- applyHeadersToRequest(req, nil, s.endpoint.Host(), serviceName)
+ applyHeadersToRequest(req, nil, s.endpoint.Host, serviceName)
res, err := s.client.Do(req)
if err != nil {
return nil, err
@@ -90,13 +90,13 @@ func NewClient(c *http.Client) transport.Transport {
}
}
-func (c *client) NewUploadPackSession(ep transport.Endpoint, auth transport.AuthMethod) (
+func (c *client) NewUploadPackSession(ep *transport.Endpoint, auth transport.AuthMethod) (
transport.UploadPackSession, error) {
return newUploadPackSession(c.c, ep, auth)
}
-func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.AuthMethod) (
+func (c *client) NewReceivePackSession(ep *transport.Endpoint, auth transport.AuthMethod) (
transport.ReceivePackSession, error) {
return newReceivePackSession(c.c, ep, auth)
@@ -105,11 +105,11 @@ func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.Aut
type session struct {
auth AuthMethod
client *http.Client
- endpoint transport.Endpoint
+ endpoint *transport.Endpoint
advRefs *packp.AdvRefs
}
-func newSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (*session, error) {
+func newSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (*session, error) {
s := &session{
auth: basicAuthFromEndpoint(ep),
client: c,
@@ -145,13 +145,13 @@ type AuthMethod interface {
setAuth(r *http.Request)
}
-func basicAuthFromEndpoint(ep transport.Endpoint) *BasicAuth {
- u := ep.User()
+func basicAuthFromEndpoint(ep *transport.Endpoint) *BasicAuth {
+ u := ep.User
if u == "" {
return nil
}
- return NewBasicAuth(u, ep.Password())
+ return NewBasicAuth(u, ep.Password)
}
// BasicAuth represent a HTTP basic auth
diff --git a/plumbing/transport/http/common_test.go b/plumbing/transport/http/common_test.go
index 8dcc903..bd1bec3 100644
--- a/plumbing/transport/http/common_test.go
+++ b/plumbing/transport/http/common_test.go
@@ -24,7 +24,7 @@ import (
func Test(t *testing.T) { TestingT(t) }
type ClientSuite struct {
- Endpoint transport.Endpoint
+ Endpoint *transport.Endpoint
EmptyAuth transport.AuthMethod
}
@@ -143,7 +143,7 @@ func (s *BaseSuite) SetUpTest(c *C) {
}()
}
-func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint {
+func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint {
fs := f.DotGit()
err := fixtures.EnsureIsBare(fs)
@@ -156,7 +156,7 @@ func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) tr
return s.newEndpoint(c, name)
}
-func (s *BaseSuite) newEndpoint(c *C, name string) transport.Endpoint {
+func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint {
ep, err := transport.NewEndpoint(fmt.Sprintf("http://localhost:%d/%s", s.port, name))
c.Assert(err, IsNil)
diff --git a/plumbing/transport/http/receive_pack.go b/plumbing/transport/http/receive_pack.go
index d2dfeb7..e5cae28 100644
--- a/plumbing/transport/http/receive_pack.go
+++ b/plumbing/transport/http/receive_pack.go
@@ -19,7 +19,7 @@ type rpSession struct {
*session
}
-func newReceivePackSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) {
+func newReceivePackSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) {
s, err := newSession(c, ep, auth)
return &rpSession{s}, err
}
@@ -89,7 +89,7 @@ func (s *rpSession) doRequest(
return nil, plumbing.NewPermanentError(err)
}
- applyHeadersToRequest(req, content, s.endpoint.Host(), transport.ReceivePackServiceName)
+ applyHeadersToRequest(req, content, s.endpoint.Host, transport.ReceivePackServiceName)
s.applyAuthToRequest(req)
res, err := s.client.Do(req.WithContext(ctx))
diff --git a/plumbing/transport/http/upload_pack.go b/plumbing/transport/http/upload_pack.go
index c5ac325..85a57a5 100644
--- a/plumbing/transport/http/upload_pack.go
+++ b/plumbing/transport/http/upload_pack.go
@@ -19,9 +19,8 @@ type upSession struct {
*session
}
-func newUploadPackSession(c *http.Client, ep transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) {
+func newUploadPackSession(c *http.Client, ep *transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) {
s, err := newSession(c, ep, auth)
-
return &upSession{s}, err
}
@@ -88,7 +87,7 @@ func (s *upSession) doRequest(
return nil, plumbing.NewPermanentError(err)
}
- applyHeadersToRequest(req, content, s.endpoint.Host(), transport.UploadPackServiceName)
+ applyHeadersToRequest(req, content, s.endpoint.Host, transport.UploadPackServiceName)
s.applyAuthToRequest(req)
res, err := s.client.Do(req.WithContext(ctx))
diff --git a/plumbing/transport/http/upload_pack_test.go b/plumbing/transport/http/upload_pack_test.go
index 1785c40..6c90386 100644
--- a/plumbing/transport/http/upload_pack_test.go
+++ b/plumbing/transport/http/upload_pack_test.go
@@ -57,7 +57,7 @@ func (s *UploadPackSuite) TestuploadPackRequestToReader(c *C) {
)
}
-func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint {
+func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint {
fs := f.DotGit()
err := fixtures.EnsureIsBare(fs)
@@ -70,7 +70,7 @@ func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name stri
return s.newEndpoint(c, name)
}
-func (s *UploadPackSuite) newEndpoint(c *C, name string) transport.Endpoint {
+func (s *UploadPackSuite) newEndpoint(c *C, name string) *transport.Endpoint {
ep, err := transport.NewEndpoint(fmt.Sprintf("http://localhost:%d/%s", s.port, name))
c.Assert(err, IsNil)
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index 598c6b1..8ec1ea5 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -39,7 +39,7 @@ type Commander interface {
// error should be returned if the endpoint is not supported or the
// command cannot be created (e.g. binary does not exist, connection
// cannot be established).
- Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (Command, error)
+ Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (Command, error)
}
// Command is used for a single command execution.
@@ -83,14 +83,14 @@ func NewClient(runner Commander) transport.Transport {
}
// NewUploadPackSession creates a new UploadPackSession.
-func (c *client) NewUploadPackSession(ep transport.Endpoint, auth transport.AuthMethod) (
+func (c *client) NewUploadPackSession(ep *transport.Endpoint, auth transport.AuthMethod) (
transport.UploadPackSession, error) {
return c.newSession(transport.UploadPackServiceName, ep, auth)
}
// NewReceivePackSession creates a new ReceivePackSession.
-func (c *client) NewReceivePackSession(ep transport.Endpoint, auth transport.AuthMethod) (
+func (c *client) NewReceivePackSession(ep *transport.Endpoint, auth transport.AuthMethod) (
transport.ReceivePackSession, error) {
return c.newSession(transport.ReceivePackServiceName, ep, auth)
@@ -108,7 +108,7 @@ type session struct {
firstErrLine chan string
}
-func (c *client) newSession(s string, ep transport.Endpoint, auth transport.AuthMethod) (*session, error) {
+func (c *client) newSession(s string, ep *transport.Endpoint, auth transport.AuthMethod) (*session, error) {
cmd, err := c.cmdr.Command(s, ep, auth)
if err != nil {
return nil, err
diff --git a/plumbing/transport/server/loader.go b/plumbing/transport/server/loader.go
index 028ead4..3af55e1 100644
--- a/plumbing/transport/server/loader.go
+++ b/plumbing/transport/server/loader.go
@@ -17,7 +17,7 @@ type Loader interface {
// Load loads a storer.Storer given a transport.Endpoint.
// Returns transport.ErrRepositoryNotFound if the repository does not
// exist.
- Load(ep transport.Endpoint) (storer.Storer, error)
+ Load(ep *transport.Endpoint) (storer.Storer, error)
}
type fsLoader struct {
@@ -33,8 +33,8 @@ func NewFilesystemLoader(base billy.Filesystem) Loader {
// Load looks up the endpoint's path in the base file system and returns a
// storer for it. Returns transport.ErrRepositoryNotFound if a repository does
// not exist in the given path.
-func (l *fsLoader) Load(ep transport.Endpoint) (storer.Storer, error) {
- fs, err := l.base.Chroot(ep.Path())
+func (l *fsLoader) Load(ep *transport.Endpoint) (storer.Storer, error) {
+ fs, err := l.base.Chroot(ep.Path)
if err != nil {
return nil, err
}
@@ -53,7 +53,7 @@ type MapLoader map[string]storer.Storer
// Load returns a storer.Storer for given a transport.Endpoint by looking it up
// in the map. Returns transport.ErrRepositoryNotFound if the endpoint does not
// exist.
-func (l MapLoader) Load(ep transport.Endpoint) (storer.Storer, error) {
+func (l MapLoader) Load(ep *transport.Endpoint) (storer.Storer, error) {
s, ok := l[ep.String()]
if !ok {
return nil, transport.ErrRepositoryNotFound
diff --git a/plumbing/transport/server/loader_test.go b/plumbing/transport/server/loader_test.go
index 38fabe3..f35511d 100644
--- a/plumbing/transport/server/loader_test.go
+++ b/plumbing/transport/server/loader_test.go
@@ -26,7 +26,7 @@ func (s *LoaderSuite) SetUpSuite(c *C) {
c.Assert(exec.Command("git", "init", "--bare", s.RepoPath).Run(), IsNil)
}
-func (s *LoaderSuite) endpoint(c *C, url string) transport.Endpoint {
+func (s *LoaderSuite) endpoint(c *C, url string) *transport.Endpoint {
ep, err := transport.NewEndpoint(url)
c.Assert(err, IsNil)
return ep
diff --git a/plumbing/transport/server/receive_pack_test.go b/plumbing/transport/server/receive_pack_test.go
index 54c2fba..39fa979 100644
--- a/plumbing/transport/server/receive_pack_test.go
+++ b/plumbing/transport/server/receive_pack_test.go
@@ -2,14 +2,12 @@ package server_test
import (
"gopkg.in/src-d/go-git.v4/plumbing/transport"
- "gopkg.in/src-d/go-git.v4/plumbing/transport/test"
. "gopkg.in/check.v1"
)
type ReceivePackSuite struct {
BaseSuite
- test.ReceivePackSuite
}
var _ = Suite(&ReceivePackSuite{})
@@ -20,7 +18,7 @@ func (s *ReceivePackSuite) SetUpSuite(c *C) {
}
func (s *ReceivePackSuite) SetUpTest(c *C) {
- s.prepareRepositories(c, &s.Endpoint, &s.EmptyEndpoint, &s.NonExistentEndpoint)
+ s.prepareRepositories(c)
}
func (s *ReceivePackSuite) TearDownTest(c *C) {
diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go
index f896f7a..2357bd6 100644
--- a/plumbing/transport/server/server.go
+++ b/plumbing/transport/server/server.go
@@ -43,7 +43,7 @@ func NewClient(loader Loader) transport.Transport {
}
}
-func (s *server) NewUploadPackSession(ep transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) {
+func (s *server) NewUploadPackSession(ep *transport.Endpoint, auth transport.AuthMethod) (transport.UploadPackSession, error) {
sto, err := s.loader.Load(ep)
if err != nil {
return nil, err
@@ -52,7 +52,7 @@ func (s *server) NewUploadPackSession(ep transport.Endpoint, auth transport.Auth
return s.handler.NewUploadPackSession(sto)
}
-func (s *server) NewReceivePackSession(ep transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) {
+func (s *server) NewReceivePackSession(ep *transport.Endpoint, auth transport.AuthMethod) (transport.ReceivePackSession, error) {
sto, err := s.loader.Load(ep)
if err != nil {
return nil, err
diff --git a/plumbing/transport/server/server_test.go b/plumbing/transport/server/server_test.go
index 7912768..335aeae 100644
--- a/plumbing/transport/server/server_test.go
+++ b/plumbing/transport/server/server_test.go
@@ -7,6 +7,7 @@ import (
"gopkg.in/src-d/go-git.v4/plumbing/transport"
"gopkg.in/src-d/go-git.v4/plumbing/transport/client"
"gopkg.in/src-d/go-git.v4/plumbing/transport/server"
+ "gopkg.in/src-d/go-git.v4/plumbing/transport/test"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/memory"
@@ -17,6 +18,8 @@ func Test(t *testing.T) { TestingT(t) }
type BaseSuite struct {
fixtures.Suite
+ test.ReceivePackSuite
+
loader server.MapLoader
client transport.Transport
clientBackup transport.Transport
@@ -44,27 +47,19 @@ func (s *BaseSuite) TearDownSuite(c *C) {
}
}
-func (s *BaseSuite) prepareRepositories(c *C, basic *transport.Endpoint,
- empty *transport.Endpoint, nonExistent *transport.Endpoint) {
+func (s *BaseSuite) prepareRepositories(c *C) {
+ var err error
- f := fixtures.Basic().One()
- fs := f.DotGit()
- path := fs.Root()
- ep, err := transport.NewEndpoint(path)
+ fs := fixtures.Basic().One().DotGit()
+ s.Endpoint, err = transport.NewEndpoint(fs.Root())
c.Assert(err, IsNil)
- *basic = ep
- sto, err := filesystem.NewStorage(fs)
+ s.loader[s.Endpoint.String()], err = filesystem.NewStorage(fs)
c.Assert(err, IsNil)
- s.loader[ep.String()] = sto
- path = "/empty.git"
- ep, err = transport.NewEndpoint(path)
+ s.EmptyEndpoint, err = transport.NewEndpoint("/empty.git")
c.Assert(err, IsNil)
- *empty = ep
- s.loader[ep.String()] = memory.NewStorage()
+ s.loader[s.EmptyEndpoint.String()] = memory.NewStorage()
- path = "/non-existent.git"
- ep, err = transport.NewEndpoint(path)
+ s.NonExistentEndpoint, err = transport.NewEndpoint("/non-existent.git")
c.Assert(err, IsNil)
- *nonExistent = ep
}
diff --git a/plumbing/transport/server/upload_pack_test.go b/plumbing/transport/server/upload_pack_test.go
index 99473d3..f252a75 100644
--- a/plumbing/transport/server/upload_pack_test.go
+++ b/plumbing/transport/server/upload_pack_test.go
@@ -2,34 +2,23 @@ package server_test
import (
"gopkg.in/src-d/go-git.v4/plumbing/transport"
- "gopkg.in/src-d/go-git.v4/plumbing/transport/test"
. "gopkg.in/check.v1"
)
type UploadPackSuite struct {
BaseSuite
- test.UploadPackSuite
}
var _ = Suite(&UploadPackSuite{})
func (s *UploadPackSuite) SetUpSuite(c *C) {
s.BaseSuite.SetUpSuite(c)
- s.UploadPackSuite.Client = s.client
+ s.Client = s.client
}
func (s *UploadPackSuite) SetUpTest(c *C) {
- s.prepareRepositories(c, &s.Endpoint, &s.EmptyEndpoint, &s.NonExistentEndpoint)
-}
-
-// Overwritten, it's not an error in server-side.
-func (s *UploadPackSuite) TestAdvertisedReferencesEmpty(c *C) {
- r, err := s.Client.NewUploadPackSession(s.EmptyEndpoint, s.EmptyAuth)
- c.Assert(err, IsNil)
- ar, err := r.AdvertisedReferences()
- c.Assert(err, IsNil)
- c.Assert(len(ar.References), Equals, 0)
+ s.prepareRepositories(c)
}
// Overwritten, server returns error earlier.
@@ -57,5 +46,5 @@ func (s *ClientLikeUploadPackSuite) SetUpSuite(c *C) {
}
func (s *ClientLikeUploadPackSuite) TestAdvertisedReferencesEmpty(c *C) {
- s.UploadPackSuite.UploadPackSuite.TestAdvertisedReferencesEmpty(c)
+ s.UploadPackSuite.TestAdvertisedReferencesEmpty(c)
}
diff --git a/plumbing/transport/ssh/common.go b/plumbing/transport/ssh/common.go
index a844c78..b7722bb 100644
--- a/plumbing/transport/ssh/common.go
+++ b/plumbing/transport/ssh/common.go
@@ -31,7 +31,7 @@ type runner struct {
config *ssh.ClientConfig
}
-func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
+func (r *runner) Command(cmd string, ep *transport.Endpoint, auth transport.AuthMethod) (common.Command, error) {
c := &command{command: cmd, endpoint: ep, config: r.config}
if auth != nil {
c.setAuth(auth)
@@ -47,7 +47,7 @@ type command struct {
*ssh.Session
connected bool
command string
- endpoint transport.Endpoint
+ endpoint *transport.Endpoint
client *ssh.Client
auth AuthMethod
config *ssh.ClientConfig
@@ -122,8 +122,8 @@ func (c *command) connect() error {
}
func (c *command) getHostWithPort() string {
- host := c.endpoint.Host()
- port := c.endpoint.Port()
+ host := c.endpoint.Host
+ port := c.endpoint.Port
if port <= 0 {
port = DefaultPort
}
@@ -133,12 +133,12 @@ func (c *command) getHostWithPort() string {
func (c *command) setAuthFromEndpoint() error {
var err error
- c.auth, err = DefaultAuthBuilder(c.endpoint.User())
+ 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())
+func endpointToCommand(cmd string, ep *transport.Endpoint) string {
+ return fmt.Sprintf("%s '%s'", cmd, ep.Path)
}
func overrideConfig(overrides *ssh.ClientConfig, c *ssh.ClientConfig) {
diff --git a/plumbing/transport/ssh/upload_pack_test.go b/plumbing/transport/ssh/upload_pack_test.go
index 04f7b1c..f6696d1 100644
--- a/plumbing/transport/ssh/upload_pack_test.go
+++ b/plumbing/transport/ssh/upload_pack_test.go
@@ -58,7 +58,7 @@ func (s *UploadPackSuite) SetUpSuite(c *C) {
}()
}
-func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) transport.Endpoint {
+func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *transport.Endpoint {
fs := f.DotGit()
err := fixtures.EnsureIsBare(fs)
@@ -71,7 +71,7 @@ func (s *UploadPackSuite) prepareRepository(c *C, f *fixtures.Fixture, name stri
return s.newEndpoint(c, name)
}
-func (s *UploadPackSuite) newEndpoint(c *C, name string) transport.Endpoint {
+func (s *UploadPackSuite) newEndpoint(c *C, name string) *transport.Endpoint {
ep, err := transport.NewEndpoint(fmt.Sprintf(
"ssh://git@localhost:%d/%s/%s", s.port, filepath.ToSlash(s.base), name,
))
diff --git a/plumbing/transport/test/receive_pack.go b/plumbing/transport/test/receive_pack.go
index ed0f517..e089c54 100644
--- a/plumbing/transport/test/receive_pack.go
+++ b/plumbing/transport/test/receive_pack.go
@@ -21,9 +21,9 @@ import (
)
type ReceivePackSuite struct {
- Endpoint transport.Endpoint
- EmptyEndpoint transport.Endpoint
- NonExistentEndpoint transport.Endpoint
+ Endpoint *transport.Endpoint
+ EmptyEndpoint *transport.Endpoint
+ NonExistentEndpoint *transport.Endpoint
EmptyAuth transport.AuthMethod
Client transport.Transport
}
@@ -213,7 +213,7 @@ func (s *ReceivePackSuite) TestSendPackOnNonEmptyWithReportStatusWithError(c *C)
s.checkRemoteHead(c, endpoint, fixture.Head)
}
-func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep transport.Endpoint,
+func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep *transport.Endpoint,
req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture,
callAdvertisedReferences bool) (*packp.ReportStatus, error) {
url := ""
@@ -245,7 +245,7 @@ func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep transport.Endpoint,
return r.ReceivePack(context.Background(), req)
}
-func (s *ReceivePackSuite) receivePack(c *C, ep transport.Endpoint,
+func (s *ReceivePackSuite) receivePack(c *C, ep *transport.Endpoint,
req *packp.ReferenceUpdateRequest, fixture *fixtures.Fixture,
callAdvertisedReferences bool) {
@@ -269,11 +269,11 @@ func (s *ReceivePackSuite) receivePack(c *C, ep transport.Endpoint,
}
}
-func (s *ReceivePackSuite) checkRemoteHead(c *C, ep transport.Endpoint, head plumbing.Hash) {
+func (s *ReceivePackSuite) checkRemoteHead(c *C, ep *transport.Endpoint, head plumbing.Hash) {
s.checkRemoteReference(c, ep, "refs/heads/master", head)
}
-func (s *ReceivePackSuite) checkRemoteReference(c *C, ep transport.Endpoint,
+func (s *ReceivePackSuite) checkRemoteReference(c *C, ep *transport.Endpoint,
refName string, head plumbing.Hash) {
r, err := s.Client.NewUploadPackSession(ep, s.EmptyAuth)
diff --git a/plumbing/transport/test/upload_pack.go b/plumbing/transport/test/upload_pack.go
index b3acc4f..70e4e56 100644
--- a/plumbing/transport/test/upload_pack.go
+++ b/plumbing/transport/test/upload_pack.go
@@ -21,9 +21,9 @@ import (
)
type UploadPackSuite struct {
- Endpoint transport.Endpoint
- EmptyEndpoint transport.Endpoint
- NonExistentEndpoint transport.Endpoint
+ Endpoint *transport.Endpoint
+ EmptyEndpoint *transport.Endpoint
+ NonExistentEndpoint *transport.Endpoint
EmptyAuth transport.AuthMethod
Client transport.Transport
}