diff options
Diffstat (limited to 'git/test')
-rw-r--r-- | git/test/lib/helper.py | 2 | ||||
-rw-r--r-- | git/test/test_submodule.py | 29 |
2 files changed, 29 insertions, 2 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index a85ac2fd..cf5efa9e 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -107,6 +107,8 @@ def with_rw_directory(func): gc.collect() if not keep: rmtree(path) + wrapper.__name__ = func.__name__ + return wrapper def with_rw_repo(working_tree_ref, bare=False): diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index bfa0379d..eae6ab9f 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() @@ -802,6 +802,31 @@ class TestSubmodule(TestBase): # 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()) + parent.index.commit("Added submodule") + + # Adding a remote without fetching so would have no references + sm.repo.create_remote('special', 'git@server-shouldnotmatter:repo.git') + assert sm.rename(sm_name) is sm and sm.name == sm_name + assert not sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False) + + new_path = 'renamed/myname' + assert sm.move(new_path).name == new_path + + new_sm_name = "shortname" + assert sm.rename(new_sm_name) is sm + assert sm.repo.is_dirty(index=True, working_tree=False, untracked_files=False) + assert sm.exists() + + sm_mod = sm.module() + if os.path.isfile(os.path.join(sm_mod.working_tree_dir, '.git')) == sm._need_gitfile_submodules(parent.git): + assert sm_mod.git_dir.endswith(join_path_native('.git', 'modules', new_sm_name)) + # end + + @with_rw_directory def test_rename(self, rwdir): parent = git.Repo.init(os.path.join(rwdir, 'parent')) sm_name = 'mymodules/myname' |