@@ -321,11 +321,13 @@ def test_base_rw(self, rwrepo):
321
321
def test_base_bare (self , rwrepo ):
322
322
self ._do_base_tests (rwrepo )
323
323
324
- def test_root_module (self ):
324
+ @with_rw_repo (k_subm_current , bare = False )
325
+ def test_root_module (self , rwrepo ):
325
326
# Can query everything without problems
326
327
rm = RootModule (self .rorepo )
327
328
assert rm .module () is self .rorepo
328
329
330
+ # try attributes
329
331
rm .binsha
330
332
rm .mode
331
333
rm .path
@@ -339,8 +341,46 @@ def test_root_module(self):
339
341
rm .config_writer ()
340
342
341
343
# deep traversal gitdb / async
342
- assert len (list (rm .traverse ())) == 2
344
+ rsms = list (rm .traverse ())
345
+ assert len (rsms ) == 2 # gitdb and async, async being a child of gitdb
343
346
344
- # cannot set the parent commit as repo name doesn 't exist
347
+ # cannot set the parent commit as root module's path didn 't exist
345
348
self .failUnlessRaises (ValueError , rm .set_parent_commit , 'HEAD' )
346
349
350
+ # TEST UPDATE
351
+ #############
352
+ # setup commit which remove existing, add new and modify existing submodules
353
+ rm = RootModule (rwrepo )
354
+ assert len (rm .children ()) == 1
355
+
356
+ # modify path
357
+ sm = rm .children ()[0 ]
358
+ pp = "path/prefix"
359
+ sm .config_writer ().set_value ('path' , join_path_native (pp , sm .path ))
360
+ cpathchange = rwrepo .index .commit ("changed sm path" )
361
+
362
+ # add submodule
363
+ nsmn = "newsubmodule"
364
+ nsmp = "submrepo"
365
+ nsm = Submodule .add (rwrepo , nsmn , nsmp , url = join_path_native (self .rorepo .working_tree_dir , rsms [0 ].path , rsms [1 ].path ))
366
+ csmadded = rwrepo .index .commit ("Added submodule" )
367
+
368
+ # remove submodule - the previous one
369
+ sm .set_parent_commit (csmadded )
370
+ assert not sm .remove ().exists ()
371
+ csmremoved = rwrepo .index .commit ("Removed submodule" )
372
+
373
+ # change url - to the first repository, this way we have a fast checkout, and a completely different
374
+ # repository at the different url
375
+ nsm .set_parent_commit (csmremoved )
376
+ nsm .config_writer ().set_value ('url' , join_path_native (self .rorepo .working_tree_dir , rsms [0 ].path ))
377
+ csmpathchange = rwrepo .index .commit ("changed url" )
378
+
379
+ # change branch
380
+ nsm .set_parent_commit (csmpathchange )
381
+ # the branch used here is an old failure branch which should ideally stay ... lets see how long that works ;)
382
+ nbn = 'pack_offset_cache'
383
+ assert nsm .branch .name != nbn
384
+ nsm .config_writer ().set_value (Submodule .k_head_option , nbn )
385
+ csmbranchchange = rwrepo .index .commit ("changed branch" )
386
+
0 commit comments