Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
remote capability negociation
Browse files Browse the repository at this point in the history
  • Loading branch information
mcuadros committed Nov 30, 2016
1 parent 7114b29 commit 7ef39c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ func (c *MockFetchPackSession) AdvertisedReferences() (*packp.AdvRefs, error) {
func (c *MockFetchPackSession) FetchPack(
r *packp.UploadPackRequest) (io.ReadCloser, error) {

if !r.Capabilities.Supports(capability.Agent) {
return nil, fmt.Errorf("" +
"invalid test rquest, missing Agent capability, the request" +
"should be created using NewUploadPackRequestFromCapabilities",
)
}

f := fixtures.ByURL(c.endpoint.String())

if len(r.Wants) == 1 {
Expand Down
6 changes: 3 additions & 3 deletions remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*plumbing.Referen
func (r *Remote) buildRequest(
s storer.ReferenceStorer, o *FetchOptions, refs []*plumbing.Reference,
) (*packp.UploadPackRequest, error) {
req := packp.NewUploadPackRequest()
req := packp.NewUploadPackRequestFromCapabilities(r.advRefs.Capabilities)
req.Depth = packp.DepthCommits(o.Depth)

for _, ref := range refs {
req.Want(ref.Hash())
req.Wants = append(req.Wants, ref.Hash())
}

i, err := s.IterReferences()
Expand All @@ -188,7 +188,7 @@ func (r *Remote) buildRequest(
return nil
}

req.Have(ref.Hash())
req.Haves = append(req.Haves, ref.Hash())
return nil
})

Expand Down

0 comments on commit 7ef39c8

Please sign in to comment.