MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_push_negotiation

Function test_push_negotiation

test/test_remote.py:558–589  ·  view source on GitHub ↗
(
    origin: Repository, clone: Repository, remote: Remote
)

Source from the content-addressed store, hash-verified

556
557
558def test_push_negotiation(
559 origin: Repository, clone: Repository, remote: Remote
560) -> None:
561 old_tip = clone[clone.head.target]
562 new_tip_id = clone.create_commit(
563 'refs/heads/master',
564 old_tip.author,
565 old_tip.author,
566 'empty commit',
567 old_tip.tree.id,
568 [old_tip.id],
569 )
570
571 the_updates: list[PushUpdate] = []
572
573 class MyCallbacks(pygit2.RemoteCallbacks):
574 def push_negotiation(self, updates: list[PushUpdate]) -> None:
575 the_updates.extend(updates)
576
577 assert origin.branches['master'].target == old_tip.id
578 assert 'new_branch' not in origin.branches
579
580 callbacks = MyCallbacks()
581 remote.push(['refs/heads/master'], callbacks=callbacks)
582
583 assert len(the_updates) == 1
584 assert the_updates[0].src_refname == 'refs/heads/master'
585 assert the_updates[0].dst_refname == 'refs/heads/master'
586 assert the_updates[0].src == old_tip.id
587 assert the_updates[0].dst == new_tip_id
588
589 assert origin.branches['master'].target == new_tip_id

Callers

nothing calls this directly

Calls 2

pushMethod · 0.80
MyCallbacksClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…