summaryrefslogtreecommitdiff
path: root/git/test/test_submodule.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2015-01-19 16:57:11 +0100
committerSebastian Thiel <byronimo@gmail.com>2015-01-19 16:57:11 +0100
commit20863cfe4a1b0c5bea18677470a969073570e41c (patch)
tree3e64226fb902a4558ba1765f7f4fa6d4cc8a2524 /git/test/test_submodule.py
parenta223c7b7730c53c3fa1e4c019bd3daefbb8fd74b (diff)
downloadgitpython-20863cfe4a1b0c5bea18677470a969073570e41c.tar.gz
Implemented Submodule.rename()
A test verifies it's truly working. Related to #238
Diffstat (limited to 'git/test/test_submodule.py')
-rw-r--r--git/test/test_submodule.py23
1 files changed, 23 insertions, 0 deletions
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