(barerepo: Repository)
| 233 | |
| 234 | |
| 235 | def 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 | |
| 269 | def test_diff_empty_tree(barerepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…