(testrepo: Repository)
| 395 | |
| 396 | |
| 397 | def test_stash(testrepo: Repository) -> None: |
| 398 | stash_hash = '6aab5192f88018cb98a7ede99c242f43add5a2fd' |
| 399 | stash_message = 'custom stash message' |
| 400 | sig = pygit2.Signature( |
| 401 | name='Stasher', |
| 402 | email='stasher@example.com', |
| 403 | time=1641000000, # fixed time so the oid is stable |
| 404 | offset=0, |
| 405 | ) |
| 406 | |
| 407 | # make sure we're starting with no stashes |
| 408 | assert [] == testrepo.listall_stashes() |
| 409 | |
| 410 | # some changes to working dir |
| 411 | with (Path(testrepo.workdir) / 'hello.txt').open('w') as f: |
| 412 | f.write('new content') |
| 413 | |
| 414 | testrepo.stash(sig, include_untracked=True, message=stash_message) |
| 415 | assert 'hello.txt' not in testrepo.status() |
| 416 | |
| 417 | repo_stashes = testrepo.listall_stashes() |
| 418 | assert 1 == len(repo_stashes) |
| 419 | assert repr(repo_stashes[0]) == f'<pygit2.Stash{{{stash_hash}}}>' |
| 420 | assert repo_stashes[0].commit_id == stash_hash |
| 421 | assert repo_stashes[0].message == 'On master: ' + stash_message |
| 422 | |
| 423 | testrepo.stash_apply() |
| 424 | assert 'hello.txt' in testrepo.status() |
| 425 | assert repo_stashes == testrepo.listall_stashes() # still the same stashes |
| 426 | |
| 427 | testrepo.stash_drop() |
| 428 | assert [] == testrepo.listall_stashes() |
| 429 | |
| 430 | with pytest.raises(KeyError): |
| 431 | testrepo.stash_pop() |
| 432 | |
| 433 | |
| 434 | def test_stash_partial(testrepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…