diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-11-18 21:36:01 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-11-18 21:36:01 +0100 |
commit | 3f2d76ba8e6d004ff5849ed8c7c34f6a4ac2e1e3 (patch) | |
tree | 87676711ab053ed2c2abc16cbe58bb2ed20a4bea /test/git/test_submodule.py | |
parent | cf5eaddde33e983bc7b496f458bdd49154f6f498 (diff) | |
download | gitpython-3f2d76ba8e6d004ff5849ed8c7c34f6a4ac2e1e3.tar.gz |
Added test for branch changes - it appears to work well, at least as far as the restricted tests are concerned
Diffstat (limited to 'test/git/test_submodule.py')
-rw-r--r-- | test/git/test_submodule.py | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/test/git/test_submodule.py b/test/git/test_submodule.py index 5e209f1b..dbc2ef08 100644 --- a/test/git/test_submodule.py +++ b/test/git/test_submodule.py @@ -437,16 +437,34 @@ class TestSubmodule(TestBase): # head changed, as the remote url and its commit changed assert prev_commit != nsm.module().head.commit - assert False + # add the submodule's changed commit to the index, which is what the + # user would do + # beforehand, update our instance's binsha with the new one + nsm.binsha = nsm.module().head.commit.binsha + rwrepo.index.add([nsm]) # change branch #================= - nsm.set_parent_commit(csmpathchange) - # the branch used here is an old failure branch which should ideally stay ... lets see how long that works ;) - nbn = 'pack_offset_cache' - assert nsm.branch.name != nbn - nsm.config_writer().set_value(Submodule.k_head_option, nbn) - csmbranchchange = rwrepo.index.commit("changed branch") + # we only have one branch, so we switch to a virtual one, and back + # to the current one to trigger the difference + cur_branch = nsm.branch + nsmm = nsm.module() + prev_commit = nsmm.head.commit + for branch in ("some_virtual_branch", cur_branch.name): + nsm.config_writer().set_value(Submodule.k_head_option, branch) + csmbranchchange = rwrepo.index.commit("changed branch to %s" % branch) + nsm.set_parent_commit(csmbranchchange) + # END for each branch to change + + # Lets remove our tracking branch to simulate some changes + nsmmh = nsmm.head + assert nsmmh.ref.tracking_branch() is None # never set it up until now + assert not nsmmh.is_detached + + rm.update(recursive=False) + + assert nsmmh.ref.tracking_branch() is not None + assert not nsmmh.is_detached # recursive update |