Skip to content

Commit 0676a21

Browse files
aymanbagabasonee-only
authored andcommitted
internal: test, receive pack only send packfile if there are non-delete commands
1 parent 41d240d commit 0676a21

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

internal/transport/test/receive_pack.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,21 @@ func (s *ReceivePackSuite) receivePackNoCheck(ep *transport.Endpoint,
274274
s.Require().NotNil(info, comment)
275275
}
276276

277-
if fixture != nil {
278-
s.Require().NotNil(fixture.Packfile())
279-
req.Packfile = fixture.Packfile()
280-
} else {
281-
req.Packfile = s.emptyPackfile()
277+
var needPackfile bool
278+
for _, cmd := range req.Commands {
279+
if cmd.Action() != packp.Delete {
280+
needPackfile = true
281+
break
282+
}
283+
}
284+
285+
if needPackfile {
286+
if fixture != nil {
287+
s.Require().NotNil(fixture.Packfile())
288+
req.Packfile = fixture.Packfile()
289+
} else {
290+
req.Packfile = s.emptyPackfile()
291+
}
282292
}
283293

284294
return conn.Push(ctx, req)
@@ -370,9 +380,6 @@ func (s *ReceivePackSuite) testSendPackAddReference() {
370380
{Name: "refs/heads/newbranch", Old: plumbing.ZeroHash, New: plumbing.NewHash(fixture.Head)},
371381
},
372382
}
373-
// if refs.Capabilities.Supports(capability.ReportStatus) {
374-
// req.Capabilities.Set(capability.ReportStatus)
375-
// }
376383

377384
s.receivePack(s.Endpoint, req, fixture, false)
378385
s.checkRemoteReference(s.Endpoint, "refs/heads/newbranch", plumbing.NewHash(fixture.Head))
@@ -400,9 +407,6 @@ func (s *ReceivePackSuite) testSendPackDeleteReference() {
400407
{Name: "refs/heads/newbranch", Old: plumbing.NewHash(fixture.Head), New: plumbing.ZeroHash},
401408
},
402409
}
403-
// if refs.Capabilities.Supports(capability.ReportStatus) {
404-
// req.Capabilities.Set(capability.ReportStatus)
405-
// }
406410

407411
if !caps.Supports(capability.DeleteRefs) {
408412
s.Fail("capability delete-refs not supported")

0 commit comments

Comments
 (0)