diff options
author | Alberto Cortés <alcortesm@gmail.com> | 2016-10-27 20:12:24 +0200 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-10-27 18:12:24 +0000 |
commit | 5944d8a185ff1f91e0e108dab1d756fd88692c3b (patch) | |
tree | 06d6fc8f9c8c6a579d518d289ffab8be70ce008d /clients/ssh/git_upload_pack_test.go | |
parent | 0c6c4047155692caff733d0cd239b80508b7bd04 (diff) | |
download | go-git-5944d8a185ff1f91e0e108dab1d756fd88692c3b.tar.gz |
Fix ssh workflow (#96)
* Fix #80
We were sending an additional `\n` to the server when sending the
upload request, see clients/ssh/git_upload_pack.go:174:
fmt.Fprintln(si, r.String())
The reason for this was to flush the input stream, otherwise, the
message was not send to the server.
Also, we were (and still are) not checking remote execution errors, so
we were unaware of this error, reading the first portion of the packfile
as if nothing were wrong.
On the few ocasions when the server was quick enough to fail before
sending the full packfile, one of our tests (the one that checks the
received packfile size) failed.
We were also escaping the repository name in the remote command
execution string incorrectly.
Now we are:
- using ssh.Run to run the remote command, instead of start and wait,
which is the same but simpler.
- using io.Copy instead of fmt.Fprintln, so we avoid adding and extra EOL and also we don't use a line buffered stream.
and we no longer have to flush it.
- we are closing the input stream as soon as possible, so the remote
command can exit also as soon as possible.
- the remote command escape character (') is used correctly
* WIP
* ssh: return remote command exit value when closing the packfile stream
Diffstat (limited to 'clients/ssh/git_upload_pack_test.go')
-rw-r--r-- | clients/ssh/git_upload_pack_test.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clients/ssh/git_upload_pack_test.go b/clients/ssh/git_upload_pack_test.go index 7a47f33..ff27cc2 100644 --- a/clients/ssh/git_upload_pack_test.go +++ b/clients/ssh/git_upload_pack_test.go @@ -121,10 +121,21 @@ func (s *RemoteSuite) TestFetch(c *C) { req.Want(core.NewHash("e8d3ffab552895c19b9fcf7aa264d277cde33881")) reader, err := r.Fetch(req) c.Assert(err, IsNil) + defer func() { c.Assert(reader.Close(), IsNil) }() b, err := ioutil.ReadAll(reader) c.Assert(err, IsNil) - - //this is failling randomly, should be fixed ASAP c.Check(len(b), Equals, 85585) } + +func (s *RemoteSuite) TestFetchError(c *C) { + r := NewGitUploadPackService(s.Endpoint) + c.Assert(r.Connect(), IsNil) + defer func() { c.Assert(r.Disconnect(), IsNil) }() + + req := &common.GitUploadPackRequest{} + req.Want(core.NewHash("1111111111111111111111111111111111111111")) + + _, err := r.Fetch(req) + c.Assert(err, Not(IsNil)) +} |