From 361854d1782b8f59dc02aa37cfe285df66048ce6 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Sun, 2 Oct 2016 10:13:22 -0400 Subject: TST: Add test for removing submodule with remotes without refs --- git/test/test_submodule.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index bfa0379d..6dcf1831 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -317,8 +317,8 @@ class TestSubmodule(TestBase): # forcibly delete the child repository prev_count = len(sm.children()) self.failUnlessRaises(ValueError, csm.remove, force=True) - # We removed sm, which removed all submodules. Howver, the instance we have - # still points to the commit prior to that, where it still existed + # We removed sm, which removed all submodules. However, the instance we + # have still points to the commit prior to that, where it still existed csm.set_parent_commit(csm.repo.commit(), check=False) assert not csm.exists() assert not csm.module_exists() @@ -801,6 +801,24 @@ class TestSubmodule(TestBase): assert os.path.isdir(sm_module_path) == dry_run # end for each dry-run mode + @with_rw_directory + def test_remove_norefs(self, rwdir): + parent = git.Repo.init(os.path.join(rwdir, 'parent')) + sm_name = 'mymodules/myname' + sm = parent.create_submodule(sm_name, sm_name, url=self._small_repo_url()) + assert sm.exists() + + parent.index.commit("Added submodule") + + assert sm.repo is parent # yoh was surprised since expected sm repo!! + # so created a new instance for submodule + smrepo = git.Repo(os.path.join(rwdir, 'parent', sm.path)) + # Adding a remote without fetching so would have no references + smrepo.create_remote('special', 'git@server-shouldnotmatter:repo.git') + # And we should be able to remove it just fine + sm.remove() + assert not sm.exists() + @with_rw_directory def test_rename(self, rwdir): parent = git.Repo.init(os.path.join(rwdir, 'parent')) -- cgit v1.2.1