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

Function test_delete

test/test_refs.py:604–629  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

602
603
604def test_delete(testrepo: Repository) -> None:
605 repo = testrepo
606
607 # We add a tag as a new reference that points to "origin/master"
608 reference = repo.create_reference('refs/tags/version1', LAST_COMMIT)
609 assert 'refs/tags/version1' in repo.listall_references()
610 assert b'refs/tags/version1' in repo.raw_listall_references()
611
612 # And we delete it
613 reference.delete()
614 assert 'refs/tags/version1' not in repo.listall_references()
615 assert b'refs/tags/version1' not in repo.raw_listall_references()
616
617 # Access the deleted reference
618 with pytest.raises(GitError):
619 getattr(reference, 'name')
620 with pytest.raises(GitError):
621 getattr(reference, 'type')
622 with pytest.raises(GitError):
623 getattr(reference, 'target')
624 with pytest.raises(GitError):
625 reference.delete()
626 with pytest.raises(GitError):
627 reference.resolve()
628 with pytest.raises(GitError):
629 reference.rename('refs/tags/version2')
630
631
632def test_rename(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 4

create_referenceMethod · 0.80
listall_referencesMethod · 0.80
deleteMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…