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

Commit 7ef39c8

Browse files
committed
remote capability negociation
1 parent 7114b29 commit 7ef39c8

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

common_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ func (c *MockFetchPackSession) AdvertisedReferences() (*packp.AdvRefs, error) {
119119
func (c *MockFetchPackSession) FetchPack(
120120
r *packp.UploadPackRequest) (io.ReadCloser, error) {
121121

122+
if !r.Capabilities.Supports(capability.Agent) {
123+
return nil, fmt.Errorf("" +
124+
"invalid test rquest, missing Agent capability, the request" +
125+
"should be created using NewUploadPackRequestFromCapabilities",
126+
)
127+
}
128+
122129
f := fixtures.ByURL(c.endpoint.String())
123130

124131
if len(r.Wants) == 1 {

remote.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ func (r *Remote) getWantedReferences(spec []config.RefSpec) ([]*plumbing.Referen
171171
func (r *Remote) buildRequest(
172172
s storer.ReferenceStorer, o *FetchOptions, refs []*plumbing.Reference,
173173
) (*packp.UploadPackRequest, error) {
174-
req := packp.NewUploadPackRequest()
174+
req := packp.NewUploadPackRequestFromCapabilities(r.advRefs.Capabilities)
175175
req.Depth = packp.DepthCommits(o.Depth)
176176

177177
for _, ref := range refs {
178-
req.Want(ref.Hash())
178+
req.Wants = append(req.Wants, ref.Hash())
179179
}
180180

181181
i, err := s.IterReferences()
@@ -188,7 +188,7 @@ func (r *Remote) buildRequest(
188188
return nil
189189
}
190190

191-
req.Have(ref.Hash())
191+
req.Haves = append(req.Haves, ref.Hash())
192192
return nil
193193
})
194194

0 commit comments

Comments
 (0)