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

Function test_diff_tree

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

Source from the content-addressed store, hash-verified

233
234
235def test_diff_tree(barerepo: Repository) -> None:
236 commit_a = barerepo[COMMIT_SHA1_1]
237 commit_b = barerepo[COMMIT_SHA1_2]
238
239 def _test(diff: Diff) -> None:
240 assert diff is not None
241 assert 2 == sum(map(lambda x: len(x.hunks), diff_safeiter(diff)))
242
243 patch = diff[0]
244 assert patch is not None
245 hunk = patch.hunks[0]
246 assert hunk.old_start == 1
247 assert hunk.old_lines == 1
248 assert hunk.new_start == 1
249 assert hunk.new_lines == 1
250
251 assert not patch.delta.is_binary
252 assert patch.delta.flags & DiffFlag.NOT_BINARY
253
254 for dfile in patch.delta.old_file, patch.delta.new_file:
255 assert dfile.path == 'a'
256 assert (
257 dfile.flags
258 == DiffFlag.NOT_BINARY
259 | DiffFlag.VALID_ID
260 | DiffFlag.VALID_SIZE
261 | DiffFlag.EXISTS
262 )
263 assert dfile.mode == FileMode.BLOB
264
265 _test(commit_a.tree.diff_to_tree(commit_b.tree))
266 _test(barerepo.diff(COMMIT_SHA1_1, COMMIT_SHA1_2))
267
268
269def test_diff_empty_tree(barerepo: Repository) -> None:

Callers

nothing calls this directly

Calls 3

_testFunction · 0.85
diff_to_treeMethod · 0.80
diffMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…