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

Function test_stash_progress_callback

test/test_repository.py:474–504  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

472
473
474def 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
507def test_stash_aborted_from_callbacks(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 5

openMethod · 0.80
stashMethod · 0.80
stash_applyMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…