@@ -359,44 +359,70 @@ def test_sync_broken(
359359
360360# @pytest.mark.skip("No recreation yet, #366")
361361def test_broken_submodule (
362- home_path : pathlib .Path ,
362+ user_path : pathlib .Path ,
363363 config_path : pathlib .Path ,
364364 tmp_path : pathlib .Path ,
365365 git_repo : GitSync ,
366366 create_git_dummy_repo : DummyRepoProtocol ,
367367) -> None :
368368 runner = CliRunner ()
369369
370+ deleted_submodule_repo = create_git_dummy_repo (
371+ repo_name = "deleted_submodule_repo" , testfile_filename = "dummy_file.txt"
372+ )
373+
370374 broken_repo = create_git_dummy_repo (
371375 repo_name = "broken_repo" , testfile_filename = "dummy_file.txt"
372376 )
373377
374378 # Try to recreated gitmodules by hand
375379
376380 # 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
382386 # """,
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+ # )
385400
386401 run (
387402 [
388403 "git" ,
389404 "submodule" ,
390405 "add" ,
391- "--quiet" ,
392- "--force" ,
393406 "--" ,
394- "./ " ,
407+ "../deleted_submodule_repo " ,
395408 "broken_submodule" ,
396409 ],
397410 cwd = str (broken_repo ),
398411 )
399412
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+
400426 with runner .isolated_filesystem (temp_dir = tmp_path ):
401427 config = {
402428 "~/github_projects/" : {
@@ -417,5 +443,7 @@ def test_broken_submodule(
417443 result = runner .invoke (cli , ["sync" , "broken_repo" ])
418444 output = "" .join (list (result .output ))
419445
446+ assert broken_repo_checkout .exists ()
447+
420448 assert "No url found for submodule" == output
421449 assert result .exit_code == 1
0 commit comments