@@ -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 ,
363363config_path :pathlib .Path ,
364364tmp_path :pathlib .Path ,
365365git_repo :GitSync ,
366366create_git_dummy_repo :DummyRepoProtocol ,
367367)-> None :
368368runner = CliRunner ()
369369
370+ deleted_submodule_repo = create_git_dummy_repo (
371+ repo_name = "deleted_submodule_repo" ,testfile_filename = "dummy_file.txt"
372+ )
373+
370374broken_repo = create_git_dummy_repo (
371375repo_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
386401run (
387402 [
388403"git" ,
389404"submodule" ,
390405"add" ,
391- "--quiet" ,
392- "--force" ,
393406"--" ,
394- "./ " ,
407+ "../deleted_submodule_repo " ,
395408"broken_submodule" ,
396409 ],
397410cwd = 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+
400426with runner .isolated_filesystem (temp_dir = tmp_path ):
401427config = {
402428"~/github_projects/" : {
@@ -417,5 +443,7 @@ def test_broken_submodule(
417443result = runner .invoke (cli , ["sync" ,"broken_repo" ])
418444output = "" .join (list (result .output ))
419445
446+ assert broken_repo_checkout .exists ()
447+
420448assert "No url found for submodule" == output
421449assert result .exit_code == 1