diff options
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 44 |
1 files changed, 11 insertions, 33 deletions
@@ -130,7 +130,7 @@ func (r *Remote) fetch(o *FetchOptions) (refs storer.ReferenceStorer, err error) o.RefSpecs = r.c.Fetch } - s, err := newFetchPackSession(r.c.URL) + s, err := newUploadPackSession(r.c.URL) if err != nil { return nil, err } @@ -173,25 +173,25 @@ func (r *Remote) fetch(o *FetchOptions) (refs storer.ReferenceStorer, err error) return remoteRefs, err } -func newFetchPackSession(url string) (transport.FetchPackSession, error) { +func newUploadPackSession(url string) (transport.UploadPackSession, error) { c, ep, err := newClient(url) if err != nil { return nil, err } - return c.NewFetchPackSession(ep) + return c.NewUploadPackSession(ep) } -func newSendPackSession(url string) (transport.SendPackSession, error) { +func newSendPackSession(url string) (transport.ReceivePackSession, error) { c, ep, err := newClient(url) if err != nil { return nil, err } - return c.NewSendPackSession(ep) + return c.NewReceivePackSession(ep) } -func newClient(url string) (transport.Client, transport.Endpoint, error) { +func newClient(url string) (transport.Transport, transport.Endpoint, error) { ep, err := transport.NewEndpoint(url) if err != nil { return nil, transport.Endpoint{}, err @@ -205,10 +205,10 @@ func newClient(url string) (transport.Client, transport.Endpoint, error) { return c, ep, err } -func (r *Remote) fetchPack(o *FetchOptions, s transport.FetchPackSession, +func (r *Remote) fetchPack(o *FetchOptions, s transport.UploadPackSession, req *packp.UploadPackRequest) (err error) { - reader, err := s.FetchPack(req) + reader, err := s.UploadPack(req) if err != nil { return err } @@ -219,7 +219,7 @@ func (r *Remote) fetchPack(o *FetchOptions, s transport.FetchPackSession, return err } - if err = r.updateObjectStorage( + if err = packfile.UpdateObjectStorage(r.s, buildSidebandIfSupported(req.Capabilities, reader, r.p), ); err != nil { return err @@ -406,28 +406,6 @@ func (r *Remote) newUploadPackRequest(o *FetchOptions, return req, nil } -func (r *Remote) updateObjectStorage(reader io.Reader) error { - if sw, ok := r.s.(storer.PackfileWriter); ok { - w, err := sw.PackfileWriter() - if err != nil { - return err - } - - defer w.Close() - _, err = io.Copy(w, reader) - return err - } - - stream := packfile.NewScanner(reader) - d, err := packfile.NewDecoder(stream, r.s) - if err != nil { - return err - } - - _, err = d.Decode() - return err -} - func buildSidebandIfSupported(l *capability.List, reader io.Reader, p sideband.Progress) io.Reader { var t sideband.Type @@ -532,7 +510,7 @@ func referencesToHashes(refs storer.ReferenceStorer) ([]plumbing.Hash, error) { return hs, nil } -func pushHashes(sess transport.SendPackSession, sto storer.EncodedObjectStorer, +func pushHashes(sess transport.ReceivePackSession, sto storer.EncodedObjectStorer, req *packp.ReferenceUpdateRequest, hs []plumbing.Hash) (*packp.ReportStatus, error) { rd, wr := io.Pipe() @@ -548,7 +526,7 @@ func pushHashes(sess transport.SendPackSession, sto storer.EncodedObjectStorer, done <- wr.Close() }() - rs, err := sess.SendPack(req) + rs, err := sess.ReceivePack(req) if err != nil { return nil, err } |