(barerepo: Repository)
| 209 | |
| 210 | |
| 211 | def test_conflicts_in_bare_repository(barerepo: Repository) -> None: |
| 212 | def create_conflict_file(repo: Repository, branch: Branch, content: str) -> Oid: |
| 213 | oid = repo.create_blob(content.encode('utf-8')) |
| 214 | tb = repo.TreeBuilder() |
| 215 | tb.insert('conflict', oid, FileMode.BLOB) |
| 216 | tree = tb.write() |
| 217 | |
| 218 | sig = pygit2.Signature('Author', 'author@example.com') |
| 219 | commit = repo.create_commit( |
| 220 | branch.name, sig, sig, 'Conflict', tree, [branch.target] |
| 221 | ) |
| 222 | assert commit is not None |
| 223 | return commit |
| 224 | |
| 225 | head_peeled = barerepo.head.peel() |
| 226 | assert isinstance(head_peeled, Commit) |
| 227 | b1 = barerepo.create_branch('b1', head_peeled) |
| 228 | c1 = create_conflict_file(barerepo, b1, 'ASCII - abc') |
| 229 | head_peeled = barerepo.head.peel() |
| 230 | assert isinstance(head_peeled, Commit) |
| 231 | b2 = barerepo.create_branch('b2', head_peeled) |
| 232 | c2 = create_conflict_file(barerepo, b2, 'Unicode - äüö') |
| 233 | |
| 234 | index = barerepo.merge_commits(c1, c2) |
| 235 | assert index.conflicts is not None |
| 236 | |
| 237 | # ConflictCollection does not allow calling len(...) on it directly so |
| 238 | # we have to calculate length by iterating over its entries |
| 239 | assert sum(1 for _ in index.conflicts) == 1 |
| 240 | |
| 241 | (a, t, o) = index.conflicts['conflict'] |
| 242 | diff = barerepo.merge_file_from_index(a, t, o) |
| 243 | assert ( |
| 244 | diff |
| 245 | == """<<<<<<< conflict |
| 246 | ASCII - abc |
| 247 | ======= |
| 248 | Unicode - äüö |
| 249 | >>>>>>> conflict |
| 250 | """ |
| 251 | ) |
nothing calls this directly
no test coverage detected
searching dependent graphs…