diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-06 11:36:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-06 11:36:38 +0100 |
commit | 4b5849db76905830e0124b6b9f4294ee13308e0f (patch) | |
tree | bb1761de5af4f442fae36d72ac5d0be941188c05 /plumbing/transport/file | |
parent | 11735c3b3aaa8f789dc10739a4de7ad438196000 (diff) | |
download | go-git-4b5849db76905830e0124b6b9f4294ee13308e0f.tar.gz |
transport/internal: error handling fixes and clean up (#160)
* protocol/packp: remove redundant isFlush check on AdvRefs.
* protocol/packp: improve AdvRefs documentation.
* transport: improve error handling for non-existing repos.
* protocol/packp: AdvRefs Decode now returns different errors for
empty, but syntactically correct, AdvRefs message (ErrEmptyAdvRefs)
and empty input (ErrEmptyInput).
* transport/internal/common: read stderr only when needed (ErrEmptyInput).
Close the client gracefully.
* transport/internal/common: missing stderr on non existing repository
does not block.
* transport/internal/common: buffer error messages.
* transport/file: fix changing binary name, add tests.
* transport/file: support changing git-upload-pack and git-receive-pack
binary names.
* transport/file: add tests for misbehaving servers.
* transport/internal/common: remove Stderr field.
* transport/internal/common: do not close twice.
Diffstat (limited to 'plumbing/transport/file')
-rw-r--r-- | plumbing/transport/file/common.go | 6 | ||||
-rw-r--r-- | plumbing/transport/file/fetch_pack_test.go | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/plumbing/transport/file/common.go b/plumbing/transport/file/common.go index 82cbba2..8697121 100644 --- a/plumbing/transport/file/common.go +++ b/plumbing/transport/file/common.go @@ -29,6 +29,12 @@ func NewClient(uploadPackBin, receivePackBin string) transport.Client { } func (r *runner) Command(cmd string, ep transport.Endpoint) (common.Command, error) { + switch cmd { + case transport.UploadPackServiceName: + cmd = r.UploadPackBin + case transport.ReceivePackServiceName: + cmd = r.ReceivePackBin + } return &command{cmd: exec.Command(cmd, ep.Path)}, nil } diff --git a/plumbing/transport/file/fetch_pack_test.go b/plumbing/transport/file/fetch_pack_test.go index 80f11ee..7a23285 100644 --- a/plumbing/transport/file/fetch_pack_test.go +++ b/plumbing/transport/file/fetch_pack_test.go @@ -2,6 +2,7 @@ package file import ( "fmt" + "os" "os/exec" "gopkg.in/src-d/go-git.v4/fixtures" @@ -46,3 +47,32 @@ func (s *FetchPackSuite) SetUpSuite(c *C) { c.Assert(err, IsNil) s.NonExistentEndpoint = ep } + +// TODO: fix test +func (s *FetchPackSuite) TestCommandNoOutput(c *C) { + c.Skip("failing test") + + if _, err := os.Stat("/bin/true"); os.IsNotExist(err) { + c.Skip("/bin/true not found") + } + + client := NewClient("true", "true") + session, err := client.NewFetchPackSession(s.Endpoint) + c.Assert(err, IsNil) + ar, err := session.AdvertisedReferences() + c.Assert(err, IsNil) + c.Assert(ar, IsNil) +} + +func (s *FetchPackSuite) TestMalformedInputNoErrors(c *C) { + if _, err := os.Stat("/usr/bin/yes"); os.IsNotExist(err) { + c.Skip("/usr/bin/yes not found") + } + + client := NewClient("yes", "yes") + session, err := client.NewFetchPackSession(s.Endpoint) + c.Assert(err, IsNil) + ar, err := session.AdvertisedReferences() + c.Assert(err, NotNil) + c.Assert(ar, IsNil) +} |