@@ -189,44 +189,70 @@ def test_sync_broken(
189189
190190# @pytest.mark.skip("No recreation yet, #366")
191191def test_broken_submodule (
192- home_path : pathlib .Path ,
192+ user_path : pathlib .Path ,
193193 config_path : pathlib .Path ,
194194 tmp_path : pathlib .Path ,
195195 git_repo : GitSync ,
196196 create_git_dummy_repo : DummyRepoProtocol ,
197197) -> None :
198198 runner = CliRunner ()
199199
200+ deleted_submodule_repo = create_git_dummy_repo (
201+ repo_name = "deleted_submodule_repo" , testfile_filename = "dummy_file.txt"
202+ )
203+
200204 broken_repo = create_git_dummy_repo (
201205 repo_name = "broken_repo" , testfile_filename = "dummy_file.txt"
202206 )
203207
204208 # Try to recreated gitmodules by hand
205209
206210 # gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
207- # gitmodules_file.write_text(
208- # """
209- # [submodule "broken_submodule "]
210- # path = broken_submodule
211- # url = ./
211+ # gitmodules_file.write_text(
212+ # """
213+ # [submodule "deleted_submodule_repo "]
214+ # path = deleted_submodule_repo
215+ # url = ../deleted_submodule_repo
212216 # """,
213- # encoding="utf-8",
214- # )
217+ # encoding="utf-8",
218+ # )
219+ #
220+ # run(
221+ # [
222+ # "git",
223+ # "submodule",
224+ # "init",
225+ # "--",
226+ # # "deleted_submodule_repo",
227+ # ],
228+ # cwd=str(broken_repo),
229+ # )
215230
216231 run (
217232 [
218233 "git" ,
219234 "submodule" ,
220235 "add" ,
221- "--quiet" ,
222- "--force" ,
223236 "--" ,
224- "./ " ,
237+ "../deleted_submodule_repo " ,
225238 "broken_submodule" ,
226239 ],
227240 cwd = str (broken_repo ),
228241 )
229242
243+ # Assure submodule exists
244+ gitmodules_file = pathlib .Path (broken_repo ) / ".gitmodules"
245+ assert gitmodules_file .exists ()
246+ assert "../deleted_submodule_repo" in gitmodules_file .read_text ()
247+
248+ github_projects = user_path / "github_projects"
249+ broken_repo_checkout = github_projects / "broken_repo"
250+ assert not broken_repo_checkout .exists ()
251+
252+ # Delete the submodule dependency
253+ shutil .rmtree (deleted_submodule_repo )
254+ assert not pathlib .Path (deleted_submodule_repo ).exists ()
255+
230256 with runner .isolated_filesystem (temp_dir = tmp_path ):
231257 config = {
232258 "~/github_projects/" : {
@@ -247,5 +273,7 @@ def test_broken_submodule(
247273 result = runner .invoke (cli , ["sync" , "broken_repo" ])
248274 output = "" .join (list (result .output ))
249275
276+ assert broken_repo_checkout .exists ()
277+
250278 assert "No url found for submodule" == output
251279 assert result .exit_code == 1
0 commit comments