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

Function check_writing

test/test_archive.py:35–56  ·  view source on GitHub ↗
(
    repo: Repository, treeish: str | Tree | Oid | Object, timestamp: int | None = None
)

Source from the content-addressed store, hash-verified

33
34
35def check_writing(
36 repo: Repository, treeish: str | Tree | Oid | Object, timestamp: int | None = None
37) -> None:
38 archive = tarfile.open('foo.tar', mode='w')
39 repo.write_archive(treeish, archive)
40
41 index = Index()
42 if isinstance(treeish, Object):
43 index.read_tree(treeish.peel(Tree))
44 else:
45 index.read_tree(repo[treeish].peel(Tree))
46
47 assert len(index) == len(archive.getmembers())
48
49 if timestamp:
50 fileinfo = archive.getmembers()[0]
51 assert timestamp == fileinfo.mtime
52
53 archive.close()
54 path = Path('foo.tar')
55 assert path.is_file()
56 path.unlink()
57
58
59def test_write_tree(testrepo: Repository) -> None:

Callers 2

test_write_treeFunction · 0.85
test_write_commitFunction · 0.85

Calls 5

read_treeMethod · 0.95
IndexClass · 0.90
openMethod · 0.80
write_archiveMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…