From 7d9d9bfee34ea428a127da0df900d3a26de37c38 Mon Sep 17 00:00:00 2001 From: "Santiago M. Mola" Date: Thu, 8 Dec 2016 14:24:25 +0100 Subject: plumbing/transport: allow AdvertisedReferences being called multiple times. (#165) * AdvertisedReferences is now part of transport.Session. * It is allowed to be called more than once. * It is allowed to be called before and after FetchPack/SendPack. * Implementations cache its result. --- plumbing/transport/common.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'plumbing/transport/common.go') diff --git a/plumbing/transport/common.go b/plumbing/transport/common.go index a20fa14..41813bf 100644 --- a/plumbing/transport/common.go +++ b/plumbing/transport/common.go @@ -30,8 +30,6 @@ var ( ErrAuthorizationRequired = errors.New("authorization required") ErrEmptyUploadPackRequest = errors.New("empty git-upload-pack given") ErrInvalidAuthMethod = errors.New("invalid auth method") - - ErrAdvertistedReferencesAlreadyCalled = errors.New("cannot call AdvertisedReference twice") ) const ( @@ -49,6 +47,9 @@ type Client interface { type Session interface { SetAuth(auth AuthMethod) error + // AdvertisedReferences retrieves the advertised references for a + // repository. + AdvertisedReferences() (*packp.AdvRefs, error) io.Closer } @@ -63,10 +64,6 @@ type AuthMethod interface { // In that order. type FetchPackSession interface { Session - // AdvertisedReferences retrieves the advertised references for a - // repository. It should be called before FetchPack, and it cannot be - // called after FetchPack. - AdvertisedReferences() (*packp.AdvRefs, error) // FetchPack takes a request and returns a reader for the packfile // received from the server. FetchPack(*packp.UploadPackRequest) (*packp.UploadPackResponse, error) @@ -78,10 +75,6 @@ type FetchPackSession interface { // In that order. type SendPackSession interface { Session - // AdvertisedReferences retrieves the advertised references for a - // repository. It should be called before FetchPack, and it cannot be - // called after FetchPack. - AdvertisedReferences() (*packp.AdvRefs, error) // UpdateReferences sends an update references request and returns a // writer to be used for packfile writing. //TODO: Complete signature. -- cgit