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

Function test_short_id

test/test_object.py:119–138  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

117
118
119def test_short_id(testrepo: Repository) -> None:
120 seen: dict[str, Oid] = {} # from short_id to full hex id
121
122 def test_obj(obj: Object | Commit, msg: str) -> None:
123 short_id = obj.short_id
124 msg = msg + f' short_id={short_id}'
125 already = seen.get(short_id)
126 if already:
127 assert already == obj.id
128 else:
129 seen[short_id] = obj.id
130 lookup = testrepo[short_id]
131 assert obj.id == lookup.id
132
133 for commit in testrepo.walk(testrepo.head.target):
134 test_obj(commit, f'commit#{commit.id}')
135 tree = commit.tree
136 test_obj(tree, f'tree#{tree.id}')
137 for entry in tree:
138 test_obj(testrepo[entry.id], f'entry={entry.name}#{entry.id}')
139
140
141def test_repr(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 1

test_objFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…