summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2016-10-02 10:13:22 -0400
committerYaroslav Halchenko <debian@onerussian.com>2016-10-02 10:13:22 -0400
commit31fd955dfcc8176fd65f92fa859374387d3e0095 (patch)
treefbca51a8bf234988fe715ec7b2772db2c0743315
parentf2b92c66bed6d1eea7b8aefe3405b0898fbb2019 (diff)
downloadgitpython-31fd955dfcc8176fd65f92fa859374387d3e0095.tar.gz
BF: @with_rw_directory must return decorated call
As it was - many tests were simply not accounted/run at all
-rw-r--r--git/test/lib/helper.py2
-rw-r--r--git/test/test_submodule.py29
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'