Cover v2 fetch-to-store decode cleanup · Entire
Cover v2 fetch-to-store decode cleanup
048f602→main · Soph·3mo ago·2 files·+37 added/-0 removed
Sessions
b139564a8f9b View transcript
Changes
2
docs
Mrewrite-issue-list.md +1
internal/gitproto
Mfetch_test.go +36
161 unmodified lines
162
163
164
165
166
167
168
161 unmodified lines
- Lower-level `gitproto.PushPack` rejection paths now also close the provided pack stream instead of leaking it on preflight command errors.
- `gitproto.PushPack` now also has direct closure coverage for cancellation, server-side receive-pack errors, and success.
- `gitproto` fetch tests now verify response-body closure symmetry for both v1 and v2 decode-failure paths.
- `fetchToStoreV2` now also has direct cancellation and decode-failure cleanup coverage.
- This still wants a fuller close-audit around lower-level transport interruption paths before it should be considered fully done.
### 6. Protocol v2 tag fetches request `include-tag` without capability gating
Mdocs/rewrite-issue-list.md +1
407 unmodified lines
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
407 unmodified lines
}
}
func TestFetchToStoreV2ClosesBodyOnDecodeError(t *testing.T) {
ep, err := transport.NewEndpoint("https://example.com/repo.git")
if err != nil {
t.Fatalf("parse endpoint: %v", err)
}
body := &trackingReadCloser{ReadCloser: io.NopCloser(bytes.NewBufferString(FormatPktLine("bogus\n") + "0000"))}
conn := NewConn(ep, "source", nil, roundTripperFunc(func(req *http.Request) (*http.Response, error) {
return &http.Response{
StatusCode: http.StatusOK,
Request: req,
Body: body,
}, nil
}))
caps := &V2Capabilities{
Caps: map[string]string{
"fetch": "",
},
}
desired := map[plumbing.ReferenceName]DesiredRef{
plumbing.NewBranchReferenceName("main"): {
SourceRef: plumbing.NewBranchReferenceName("main"),
TargetRef: plumbing.NewBranchReferenceName("main"),
SourceHash: plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
},
}
err = fetchToStoreV2(context.Background(), memory.NewStorage(), conn, caps, desired, nil)
if err == nil {
t.Fatal("expected decode error")
}
if !body.closed {
t.Fatal("expected response body to be closed on decode error")
}
}
func TestFetchPackV1ClosesBodyOnDecodeError(t *testing.T) {
ep, err := transport.NewEndpoint("https://example.com/repo.git")
if err != nil {