| 210 | |
| 211 | |
| 212 | def test_checkout_branch(testrepo: Repository) -> None: |
| 213 | branch_i18n = testrepo.lookup_branch('i18n') |
| 214 | |
| 215 | # checkout i18n with conflicts and default strategy should |
| 216 | # not be possible |
| 217 | with pytest.raises(pygit2.GitError): |
| 218 | testrepo.checkout(branch_i18n) |
| 219 | |
| 220 | # checkout i18n with GIT_CHECKOUT_FORCE |
| 221 | head_object = testrepo.head |
| 222 | head = testrepo[head_object.target] |
| 223 | assert 'new' not in head.tree |
| 224 | testrepo.checkout(branch_i18n, strategy=CheckoutStrategy.FORCE) |
| 225 | |
| 226 | head_object = testrepo.head |
| 227 | head = testrepo[head_object.target] |
| 228 | assert head.id == branch_i18n.target |
| 229 | assert 'new' in head.tree |
| 230 | assert 'bye.txt' not in testrepo.status() |
| 231 | |
| 232 | |
| 233 | def test_checkout_index(testrepo: Repository) -> None: |