1
1
# This module is part of GitPython and is released under
2
2
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
3
- import shutil
4
3
import sys
5
4
import os
6
5
18
17
from git .compat import string_types
19
18
from git .repo .fun import find_git_dir
20
19
21
- from nose import SkipTest
22
-
23
20
# Change the configuration if possible to prevent the underlying memory manager
24
21
# to keep file handles open. On windows we get problems as they are not properly
25
22
# closed due to mmap bugs on windows (as it appears)
@@ -46,7 +43,7 @@ def update(self, op, index, max_count, message=''):
46
43
47
44
class TestSubmodule (TestBase ):
48
45
49
- k_subm_current = "468cad66ff1f80ddaeee4123c24e4d53a032c00d "
46
+ k_subm_current = "c15a6e1923a14bc760851913858a3942a4193cdb "
50
47
k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3"
51
48
k_no_subm_tag = "0.1.6"
52
49
@@ -67,7 +64,7 @@ def _do_base_tests(self, rwrepo):
67
64
68
65
assert sm .path == 'git/ext/gitdb'
69
66
assert 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')
71
68
assert sm .branch_path == 'refs/heads/master' # the default ...
72
69
assert sm .branch_name == 'master'
73
70
assert sm .parent_commit == rwrepo .head .commit
@@ -184,7 +181,9 @@ def _do_base_tests(self, rwrepo):
184
181
assert sm .module ().head .ref .tracking_branch () is not None
185
182
186
183
# 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 )
188
187
assert len (sm .children ()) == 0
189
188
# dry-run does nothing
190
189
sm .update (dry_run = True , recursive = False , progress = prog )
@@ -277,9 +276,12 @@ def _do_base_tests(self, rwrepo):
277
276
278
277
# enforce the submodule to be checked out at the right spot as well.
279
278
csm .update ()
279
+ assert csm .module_exists ()
280
+ assert csm .exists ()
281
+ assert os .path .isdir (csm .module ().working_tree_dir )
280
282
281
283
# this would work
282
- assert sm .remove (dry_run = True ) is sm
284
+ assert sm .remove (force = True , dry_run = True ) is sm
283
285
assert sm .module_exists ()
284
286
sm .remove (force = True , dry_run = True )
285
287
assert sm .module_exists ()
@@ -291,17 +293,20 @@ def _do_base_tests(self, rwrepo):
291
293
292
294
# forcibly delete the child repository
293
295
prev_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 )
295
300
assert not csm .exists ()
296
301
assert not csm .module_exists ()
297
- assert len (sm .children ()) == prev_count - 1
302
+ assert len (sm .children ()) == prev_count
298
303
# now we have a changed index, as configuration was altered.
299
304
# fix this
300
305
sm .module ().index .reset (working_tree = True )
301
306
302
307
# now delete only the module of the main submodule
303
308
assert sm .module_exists ()
304
- sm .remove (configuration = False )
309
+ sm .remove (configuration = False , force = True )
305
310
assert sm .exists ()
306
311
assert not sm .module_exists ()
307
312
assert sm .config_reader ().get_value ('url' )
@@ -391,7 +396,6 @@ def _do_base_tests(self, rwrepo):
391
396
392
397
@with_rw_repo (k_subm_current )
393
398
def test_base_rw (self , rwrepo ):
394
- raise SkipTest ("Disabled as long as it fails and submodule support wasn't overhauled" )
395
399
self ._do_base_tests (rwrepo )
396
400
397
401
@with_rw_repo (k_subm_current , bare = True )
0 commit comments