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

Function test_diff_empty_tree

test/test_diff.py:269–285  ·  view source on GitHub ↗
(barerepo: Repository)

Source from the content-addressed store, hash-verified

267
268
269def test_diff_empty_tree(barerepo: Repository) -> None:
270 commit_a = barerepo[COMMIT_SHA1_1]
271 diff = commit_a.tree.diff_to_tree()
272
273 def get_context_for_lines(diff: Diff) -> Iterator[str]:
274 hunks = chain.from_iterable(map(lambda x: x.hunks, diff_safeiter(diff)))
275 lines = chain.from_iterable(map(lambda x: x.lines, hunks))
276 return map(lambda x: x.origin, lines)
277
278 entries = [p.delta.new_file.path for p in diff_safeiter(diff)]
279 assert all(commit_a.tree[x] for x in entries)
280 assert all('-' == x for x in get_context_for_lines(diff))
281
282 diff_swaped = commit_a.tree.diff_to_tree(swap=True)
283 entries = [p.delta.new_file.path for p in diff_safeiter(diff_swaped)]
284 assert all(commit_a.tree[x] for x in entries)
285 assert all('+' == x for x in get_context_for_lines(diff_swaped))
286
287
288def test_diff_revparse(barerepo: Repository) -> None:

Callers

nothing calls this directly

Calls 3

diff_safeiterFunction · 0.85
get_context_for_linesFunction · 0.85
diff_to_treeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…