Skip to content

Commit

Permalink
Add test for checking out local branches with a Branch object.
Browse files Browse the repository at this point in the history
This differs from the only other test which uses a Reference object.
This test only succeeds because of the previous commit.
  • Loading branch information
djmattyg007 committed Aug 23, 2014
1 parent 629eea0 commit 14bcce0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,25 @@ def test_checkout_ref(self):
self.assertTrue('new' in head.tree)
self.assertTrue('bye.txt' not in self.repo.status())

def test_checkout_branch(self):
branch_i18n = self.repo.lookup_branch('i18n')

# checkout i18n with conflicts and default strategy should
# not be possible
self.assertRaises(pygit2.GitError, self.repo.checkout, branch_i18n)

# checkout i18n with GIT_CHECKOUT_FORCE
head = self.repo.head
head = self.repo[head.target]
self.assertTrue('new' not in head.tree)
self.repo.checkout(branch_i18n, strategy=pygit2.GIT_CHECKOUT_FORCE)

head = self.repo.head
head = self.repo[head.target]
self.assertEqual(head.hex, branch_i18n.target.hex)
self.assertTrue('new' in head.tree)
self.assertTrue('bye.txt' not in self.repo.status())

def test_checkout_index(self):
# some changes to working dir
with open(os.path.join(self.repo.workdir, 'hello.txt'), 'w') as f:
Expand Down

0 comments on commit 14bcce0

Please sign in to comment.