diff options
author | Anthony Weems <amlweems@gmail.com> | 2017-01-17 11:17:11 -0600 |
---|---|---|
committer | Santiago M. Mola <santi@mola.io> | 2017-01-17 18:17:11 +0100 |
commit | 6593c757346f9817a770ff0ea091cce3e8243070 (patch) | |
tree | 6fbb72583931b0386e382177970650a9cdbca4eb /plumbing/transport/file | |
parent | 241e8ba00ac9533299d62dc38684305af2b6c301 (diff) | |
download | go-git-6593c757346f9817a770ff0ea091cce3e8243070.tar.gz |
transport: remove SetAuth, fixes #206 (#210)
* remove SetAuth functions, implement at NewUploadPackSession/NewReceivePackSession level.
* propagate transport.Auth from Fetch/Pull/Clone options to the transport API.
Diffstat (limited to 'plumbing/transport/file')
-rw-r--r-- | plumbing/transport/file/client.go | 15 | ||||
-rw-r--r-- | plumbing/transport/file/receive_pack_test.go | 6 | ||||
-rw-r--r-- | plumbing/transport/file/server.go | 6 | ||||
-rw-r--r-- | plumbing/transport/file/upload_pack_test.go | 6 |
4 files changed, 16 insertions, 17 deletions
diff --git a/plumbing/transport/file/client.go b/plumbing/transport/file/client.go index 5484009..e3f7681 100644 --- a/plumbing/transport/file/client.go +++ b/plumbing/transport/file/client.go @@ -28,13 +28,18 @@ func NewClient(uploadPackBin, receivePackBin string) transport.Transport { }) } -func (r *runner) Command(cmd string, ep transport.Endpoint) (common.Command, error) { +func (r *runner) Command(cmd string, ep transport.Endpoint, auth transport.AuthMethod) (common.Command, error) { switch cmd { case transport.UploadPackServiceName: cmd = r.UploadPackBin case transport.ReceivePackServiceName: cmd = r.ReceivePackBin } + + if _, err := exec.LookPath(cmd); err != nil { + return nil, err + } + return &command{cmd: exec.Command(cmd, ep.Path)}, nil } @@ -43,14 +48,6 @@ type command struct { closed bool } -func (c *command) SetAuth(auth transport.AuthMethod) error { - if auth != nil { - return transport.ErrInvalidAuthMethod - } - - return nil -} - func (c *command) Start() error { return c.cmd.Start() } diff --git a/plumbing/transport/file/receive_pack_test.go b/plumbing/transport/file/receive_pack_test.go index c07d4ed..1858492 100644 --- a/plumbing/transport/file/receive_pack_test.go +++ b/plumbing/transport/file/receive_pack_test.go @@ -46,7 +46,7 @@ func (s *ReceivePackSuite) TestCommandNoOutput(c *C) { } client := NewClient("true", "true") - session, err := client.NewReceivePackSession(s.Endpoint) + session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, IsNil) ar, err := session.AdvertisedReferences() c.Assert(err, IsNil) @@ -59,7 +59,7 @@ func (s *ReceivePackSuite) TestMalformedInputNoErrors(c *C) { } client := NewClient("yes", "yes") - session, err := client.NewReceivePackSession(s.Endpoint) + session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, IsNil) ar, err := session.AdvertisedReferences() c.Assert(err, NotNil) @@ -69,7 +69,7 @@ func (s *ReceivePackSuite) TestMalformedInputNoErrors(c *C) { func (s *ReceivePackSuite) TestNonExistentCommand(c *C) { cmd := "/non-existent-git" client := NewClient(cmd, cmd) - session, err := client.NewReceivePackSession(s.Endpoint) + session, err := client.NewReceivePackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, ErrorMatches, ".*no such file or directory.*") c.Assert(session, IsNil) } diff --git a/plumbing/transport/file/server.go b/plumbing/transport/file/server.go index d83d5d9..74085c2 100644 --- a/plumbing/transport/file/server.go +++ b/plumbing/transport/file/server.go @@ -19,7 +19,8 @@ func ServeUploadPack(path string) error { return err } - s, err := server.DefaultServer.NewUploadPackSession(ep) + // TODO: define and implement a server-side AuthMethod + s, err := server.DefaultServer.NewUploadPackSession(ep, nil) if err != nil { return fmt.Errorf("error creating session: %s", err) } @@ -36,7 +37,8 @@ func ServeReceivePack(path string) error { return err } - s, err := server.DefaultServer.NewReceivePackSession(ep) + // TODO: define and implement a server-side AuthMethod + s, err := server.DefaultServer.NewReceivePackSession(ep, nil) if err != nil { return fmt.Errorf("error creating session: %s", err) } diff --git a/plumbing/transport/file/upload_pack_test.go b/plumbing/transport/file/upload_pack_test.go index de232c4..d9adee2 100644 --- a/plumbing/transport/file/upload_pack_test.go +++ b/plumbing/transport/file/upload_pack_test.go @@ -52,7 +52,7 @@ func (s *UploadPackSuite) TestCommandNoOutput(c *C) { } client := NewClient("true", "true") - session, err := client.NewUploadPackSession(s.Endpoint) + session, err := client.NewUploadPackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, IsNil) ar, err := session.AdvertisedReferences() c.Assert(err, IsNil) @@ -65,7 +65,7 @@ func (s *UploadPackSuite) TestMalformedInputNoErrors(c *C) { } client := NewClient("yes", "yes") - session, err := client.NewUploadPackSession(s.Endpoint) + session, err := client.NewUploadPackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, IsNil) ar, err := session.AdvertisedReferences() c.Assert(err, NotNil) @@ -75,7 +75,7 @@ func (s *UploadPackSuite) TestMalformedInputNoErrors(c *C) { func (s *UploadPackSuite) TestNonExistentCommand(c *C) { cmd := "/non-existent-git" client := NewClient(cmd, cmd) - session, err := client.NewUploadPackSession(s.Endpoint) + session, err := client.NewUploadPackSession(s.Endpoint, s.EmptyAuth) c.Assert(err, ErrorMatches, ".*no such file or directory.*") c.Assert(session, IsNil) } |