(testrepo: Repository)
| 472 | |
| 473 | |
| 474 | def test_stash_progress_callback(testrepo: Repository) -> None: |
| 475 | sig = pygit2.Signature( |
| 476 | name='Stasher', email='stasher@example.com', time=1641000000, offset=0 |
| 477 | ) |
| 478 | |
| 479 | # some changes to working dir |
| 480 | with (Path(testrepo.workdir) / 'hello.txt').open('w') as f: |
| 481 | f.write('new content') |
| 482 | |
| 483 | # create the stash |
| 484 | testrepo.stash(sig, include_untracked=True, message='custom stash message') |
| 485 | |
| 486 | progress_sequence = [] |
| 487 | |
| 488 | class MyStashApplyCallbacks(pygit2.StashApplyCallbacks): |
| 489 | def stash_apply_progress(self, progress: StashApplyProgress) -> None: |
| 490 | progress_sequence.append(progress) |
| 491 | |
| 492 | # apply the stash |
| 493 | testrepo.stash_apply(callbacks=MyStashApplyCallbacks()) |
| 494 | |
| 495 | # make sure the callbacks were notified of all the steps |
| 496 | assert progress_sequence == [ |
| 497 | StashApplyProgress.LOADING_STASH, |
| 498 | StashApplyProgress.ANALYZE_INDEX, |
| 499 | StashApplyProgress.ANALYZE_MODIFIED, |
| 500 | StashApplyProgress.ANALYZE_UNTRACKED, |
| 501 | StashApplyProgress.CHECKOUT_UNTRACKED, |
| 502 | StashApplyProgress.CHECKOUT_MODIFIED, |
| 503 | StashApplyProgress.DONE, |
| 504 | ] |
| 505 | |
| 506 | |
| 507 | def test_stash_aborted_from_callbacks(testrepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…