diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-04 19:36:29 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-04 19:41:01 +0100 |
commit | ace1fed6321bb8dd6d38b2f58d7cf815fa16db7a (patch) | |
tree | 3878d5e0282531596d42505d8725482dde002c20 /test/git/test_refs.py | |
parent | f1e9df152219e85798d78284beeda88f6baa9ec7 (diff) | |
download | gitpython-ace1fed6321bb8dd6d38b2f58d7cf815fa16db7a.tar.gz |
head.checkout method added including test
Diffstat (limited to 'test/git/test_refs.py')
-rw-r--r-- | test/git/test_refs.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/test/git/test_refs.py b/test/git/test_refs.py index 6b3c2840..32a6de1c 100644 --- a/test/git/test_refs.py +++ b/test/git/test_refs.py @@ -211,8 +211,29 @@ class TestRefs(TestBase): assert not cur_head.is_detached assert head.commit == parent_commit + # test checkout + active_branch = rw_repo.active_branch + for head in rw_repo.heads: + checked_out_head = head.checkout() + assert checked_out_head == head + # END for each head to checkout + + # checkout with branch creation + new_head = active_branch.checkout(b="new_head") + assert active_branch != rw_repo.active_branch + assert new_head == rw_repo.active_branch + + # checkout with force has we have a change + # clear file + open(new_head.commit.tree.blobs[-1].abspath,'w').close() + assert len(new_head.commit.diff(None)) == 1 + + # create a new branch that is likely to touch the file we changed + far_away_head = rw_repo.create_head("far_head",'HEAD~100') + self.failUnlessRaises(GitCommandError, far_away_head.checkout) + assert active_branch == active_branch.checkout(force=True) + # test ref listing - assure we have packed refs rw_repo.git.pack_refs(all=True) assert rw_repo.heads assert rw_repo.tags - |