11# This module is part of GitPython and is released under
22# the BSD License: http://www.opensource.org/licenses/bsd-license.php
3- import shutil
43import sys
54import os
65
1817from git .compat import string_types
1918from git .repo .fun import find_git_dir
2019
21- from nose import SkipTest
22-
2320# Change the configuration if possible to prevent the underlying memory manager
2421# to keep file handles open. On windows we get problems as they are not properly
2522# closed due to mmap bugs on windows (as it appears)
@@ -46,7 +43,7 @@ def update(self, op, index, max_count, message=''):
4643
4744class TestSubmodule (TestBase ):
4845
49- k_subm_current = "468cad66ff1f80ddaeee4123c24e4d53a032c00d "
46+ k_subm_current = "c15a6e1923a14bc760851913858a3942a4193cdb "
5047k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
5148k_no_subm_tag = "0.1.6"
5249
@@ -67,7 +64,7 @@ def _do_base_tests(self, rwrepo):
6764
6865assert sm .path == 'git/ext/gitdb'
6966assert sm .path != sm .name # in our case, we have ids there, which don't equal the path
70- assert sm .url == 'git:// github.com/gitpython-developers/gitdb.git'
67+ assert sm .url . endswith ( ' github.com/gitpython-developers/gitdb.git')
7168assert sm .branch_path == 'refs/heads/master' # the default ...
7269assert sm .branch_name == 'master'
7370assert sm .parent_commit == rwrepo .head .commit
@@ -184,7 +181,9 @@ def _do_base_tests(self, rwrepo):
184181assert sm .module ().head .ref .tracking_branch ()is not None
185182
186183# delete the whole directory and re-initialize
187- shutil .rmtree (sm .abspath )
184+ assert len (sm .children ())!= 0
185+ # shutil.rmtree(sm.abspath)
186+ sm .remove (force = True ,configuration = False )
188187assert len (sm .children ())== 0
189188# dry-run does nothing
190189sm .update (dry_run = True ,recursive = False ,progress = prog )
@@ -277,9 +276,12 @@ def _do_base_tests(self, rwrepo):
277276
278277# enforce the submodule to be checked out at the right spot as well.
279278csm .update ()
279+ assert csm .module_exists ()
280+ assert csm .exists ()
281+ assert os .path .isdir (csm .module ().working_tree_dir )
280282
281283# this would work
282- assert sm .remove (dry_run = True )is sm
284+ assert sm .remove (force = True , dry_run = True )is sm
283285assert sm .module_exists ()
284286sm .remove (force = True ,dry_run = True )
285287assert sm .module_exists ()
@@ -291,17 +293,20 @@ def _do_base_tests(self, rwrepo):
291293
292294# forcibly delete the child repository
293295prev_count = len (sm .children ())
294- assert csm .remove (force = True )is csm
296+ self .failUnlessRaises (ValueError ,csm .remove ,force = True )
297+ # We removed sm, which removed all submodules. Howver, the instance we have
298+ # still points to the commit prior to that, where it still existed
299+ csm .set_parent_commit (csm .repo .commit (),check = False )
295300assert not csm .exists ()
296301assert not csm .module_exists ()
297- assert len (sm .children ())== prev_count - 1
302+ assert len (sm .children ())== prev_count
298303# now we have a changed index, as configuration was altered.
299304# fix this
300305sm .module ().index .reset (working_tree = True )
301306
302307# now delete only the module of the main submodule
303308assert sm .module_exists ()
304- sm .remove (configuration = False )
309+ sm .remove (configuration = False , force = True )
305310assert sm .exists ()
306311assert not sm .module_exists ()
307312assert sm .config_reader ().get_value ('url' )
@@ -391,7 +396,6 @@ def _do_base_tests(self, rwrepo):
391396
392397@with_rw_repo (k_subm_current )
393398def test_base_rw (self ,rwrepo ):
394- raise SkipTest ("Disabled as long as it fails and submodule support wasn't overhauled" )
395399self ._do_base_tests (rwrepo )
396400
397401@with_rw_repo (k_subm_current ,bare = True )