(
origin: Repository, clone: Repository, remote: Remote, reject_from: str
)
| 449 | |
| 450 | @pytest.mark.parametrize('reject_from', ['push_transfer_progress', 'push_negotiation']) |
| 451 | def test_push_interrupted_from_callbacks( |
| 452 | origin: Repository, clone: Repository, remote: Remote, reject_from: str |
| 453 | ) -> None: |
| 454 | reject_message = 'retreat! retreat!' |
| 455 | |
| 456 | tip = clone[clone.head.target] |
| 457 | clone.create_commit( |
| 458 | 'refs/heads/master', |
| 459 | tip.author, |
| 460 | tip.author, |
| 461 | 'empty commit', |
| 462 | tip.tree.id, |
| 463 | [tip.id], |
| 464 | ) |
| 465 | |
| 466 | class MyCallbacks(pygit2.RemoteCallbacks): |
| 467 | def push_negotiation(self, updates: list[PushUpdate]) -> None: |
| 468 | if reject_from == 'push_negotiation': |
| 469 | raise InterruptedError(reject_message) |
| 470 | |
| 471 | def push_transfer_progress( |
| 472 | self, objects_pushed: int, total_objects: int, bytes_pushed: int |
| 473 | ) -> None: |
| 474 | if reject_from == 'push_transfer_progress': |
| 475 | raise InterruptedError(reject_message) |
| 476 | |
| 477 | assert origin.branches['master'].target == tip.id |
| 478 | |
| 479 | callbacks = MyCallbacks() |
| 480 | with pytest.raises(InterruptedError, match='retreat! retreat!'): |
| 481 | remote.push(['refs/heads/master'], callbacks=callbacks) |
| 482 | |
| 483 | assert origin.branches['master'].target == tip.id |
| 484 | |
| 485 | |
| 486 | def test_push_non_fast_forward_commits_to_remote_fails( |
nothing calls this directly
no test coverage detected
searching dependent graphs…