diff options
Diffstat (limited to 'git/test')
-rw-r--r-- | git/test/test_config.py | 13 | ||||
-rw-r--r-- | git/test/test_repo.py | 2 | ||||
-rw-r--r-- | git/test/test_submodule.py | 23 |
3 files changed, 38 insertions, 0 deletions
diff --git a/git/test/test_config.py b/git/test/test_config.py index 9a44d9e3..286d151e 100644 --- a/git/test/test_config.py +++ b/git/test/test_config.py @@ -193,3 +193,16 @@ class TestBase(TestCase): cr = GitConfigParser(fpa, read_only=True) check_test_value(cr, tv) cr.release() + + def test_rename(self): + file_obj = self._to_memcache(fixture_path('git_config')) + cw = GitConfigParser(file_obj, read_only=False, merge_includes=False) + + self.failUnlessRaises(ValueError, cw.rename_section, "doesntexist", "foo") + self.failUnlessRaises(ValueError, cw.rename_section, "core", "include") + + nn = "bee" + assert cw.rename_section('core', nn) is cw + assert not cw.has_section('core') + assert len(cw.items(nn)) == 4 + cw.release() diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 226c1d26..c583fcae 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -164,6 +164,7 @@ class TestRepo(TestBase): r = Repo.init(path=path, bare=True) assert isinstance(r, Repo) assert r.bare is True + assert not r.has_separate_working_tree() assert os.path.isdir(r.git_dir) self._assert_empty_repo(r) @@ -200,6 +201,7 @@ class TestRepo(TestBase): os.chdir(git_dir_rela) r = Repo.init(bare=False) assert r.bare is False + assert not r.has_separate_working_tree() self._assert_empty_repo(r) finally: diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 7cd86bd9..813b15da 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -670,8 +670,10 @@ class TestSubmodule(TestBase): assert module_repo_path.startswith(os.path.join(parent.working_tree_dir, sm_path)) if not sm._need_gitfile_submodules(parent.git): assert os.path.isdir(module_repo_path) + assert not sm.module().has_separate_working_tree() else: assert os.path.isfile(module_repo_path) + assert sm.module().has_separate_working_tree() assert find_git_dir(module_repo_path) is not None, "module pointed to by .git file must be valid" # end verify submodule 'style' @@ -689,6 +691,8 @@ class TestSubmodule(TestBase): # Fails because there are new commits, compared to the remote we cloned from self.failUnlessRaises(InvalidGitRepositoryError, sm.remove, dry_run=True) + # TODO: rename nested submodule + # remove sm_module_path = sm.module().git_dir @@ -698,3 +702,22 @@ class TestSubmodule(TestBase): assert sm.module_exists() == dry_run assert os.path.isdir(sm_module_path) == dry_run # end for each dry-run mode + + @with_rw_directory + def test_rename(self, rwdir): + parent = git.Repo.init(os.path.join(rwdir, 'parent')) + sm_name = 'mymodules/myname' + sm = parent.create_submodule(sm_name, 'submodules/intermediate/one', url=self._submodule_url()) + parent.index.commit("Added submodule") + assert sm._parent_commit is not None + + assert sm.rename(sm_name) is sm and sm.name == sm_name + + new_sm_name = "shortname" + assert sm.rename(new_sm_name) is sm + 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(".git/modules/" + new_sm_name) + # end |