@@ -359,44 +359,70 @@ def test_sync_broken(
359
359
360
360
# @pytest.mark.skip("No recreation yet, #366")
361
361
def test_broken_submodule (
362
- home_path : pathlib .Path ,
362
+ user_path : pathlib .Path ,
363
363
config_path : pathlib .Path ,
364
364
tmp_path : pathlib .Path ,
365
365
git_repo : GitSync ,
366
366
create_git_dummy_repo : DummyRepoProtocol ,
367
367
) -> None :
368
368
runner = CliRunner ()
369
369
370
+ deleted_submodule_repo = create_git_dummy_repo (
371
+ repo_name = "deleted_submodule_repo" , testfile_filename = "dummy_file.txt"
372
+ )
373
+
370
374
broken_repo = create_git_dummy_repo (
371
375
repo_name = "broken_repo" , testfile_filename = "dummy_file.txt"
372
376
)
373
377
374
378
# Try to recreated gitmodules by hand
375
379
376
380
# gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
377
- # gitmodules_file.write_text(
378
- # """
379
- # [submodule "broken_submodule "]
380
- # path = broken_submodule
381
- # url = ./
381
+ # gitmodules_file.write_text(
382
+ # """
383
+ # [submodule "deleted_submodule_repo "]
384
+ # path = deleted_submodule_repo
385
+ # url = ../deleted_submodule_repo
382
386
# """,
383
- # encoding="utf-8",
384
- # )
387
+ # encoding="utf-8",
388
+ # )
389
+ #
390
+ # run(
391
+ # [
392
+ # "git",
393
+ # "submodule",
394
+ # "init",
395
+ # "--",
396
+ # # "deleted_submodule_repo",
397
+ # ],
398
+ # cwd=str(broken_repo),
399
+ # )
385
400
386
401
run (
387
402
[
388
403
"git" ,
389
404
"submodule" ,
390
405
"add" ,
391
- "--quiet" ,
392
- "--force" ,
393
406
"--" ,
394
- "./ " ,
407
+ "../deleted_submodule_repo " ,
395
408
"broken_submodule" ,
396
409
],
397
410
cwd = str (broken_repo ),
398
411
)
399
412
413
+ # Assure submodule exists
414
+ gitmodules_file = pathlib .Path (broken_repo ) / ".gitmodules"
415
+ assert gitmodules_file .exists ()
416
+ assert "../deleted_submodule_repo" in gitmodules_file .read_text ()
417
+
418
+ github_projects = user_path / "github_projects"
419
+ broken_repo_checkout = github_projects / "broken_repo"
420
+ assert not broken_repo_checkout .exists ()
421
+
422
+ # Delete the submodule dependency
423
+ shutil .rmtree (deleted_submodule_repo )
424
+ assert not pathlib .Path (deleted_submodule_repo ).exists ()
425
+
400
426
with runner .isolated_filesystem (temp_dir = tmp_path ):
401
427
config = {
402
428
"~/github_projects/" : {
@@ -417,5 +443,7 @@ def test_broken_submodule(
417
443
result = runner .invoke (cli , ["sync" , "broken_repo" ])
418
444
output = "" .join (list (result .output ))
419
445
446
+ assert broken_repo_checkout .exists ()
447
+
420
448
assert "No url found for submodule" == output
421
449
assert result .exit_code == 1
0 commit comments