@@ -262,44 +262,70 @@ def test_sync_broken(
262
262
263
263
# @pytest.mark.skip("No recreation yet, #366")
264
264
def test_broken_submodule (
265
- home_path : pathlib .Path ,
265
+ user_path : pathlib .Path ,
266
266
config_path : pathlib .Path ,
267
267
tmp_path : pathlib .Path ,
268
268
git_repo : GitSync ,
269
269
create_git_dummy_repo : DummyRepoProtocol ,
270
270
) -> None :
271
271
runner = CliRunner ()
272
272
273
+ deleted_submodule_repo = create_git_dummy_repo (
274
+ repo_name = "deleted_submodule_repo" , testfile_filename = "dummy_file.txt"
275
+ )
276
+
273
277
broken_repo = create_git_dummy_repo (
274
278
repo_name = "broken_repo" , testfile_filename = "dummy_file.txt"
275
279
)
276
280
277
281
# Try to recreated gitmodules by hand
278
282
279
283
# gitmodules_file = pathlib.Path(broken_repo) / ".gitmodules"
280
- # gitmodules_file.write_text(
281
- # """
282
- # [submodule "broken_submodule "]
283
- # path = broken_submodule
284
- # url = ./
284
+ # gitmodules_file.write_text(
285
+ # """
286
+ # [submodule "deleted_submodule_repo "]
287
+ # path = deleted_submodule_repo
288
+ # url = ../deleted_submodule_repo
285
289
# """,
286
- # encoding="utf-8",
287
- # )
290
+ # encoding="utf-8",
291
+ # )
292
+ #
293
+ # run(
294
+ # [
295
+ # "git",
296
+ # "submodule",
297
+ # "init",
298
+ # "--",
299
+ # # "deleted_submodule_repo",
300
+ # ],
301
+ # cwd=str(broken_repo),
302
+ # )
288
303
289
304
run (
290
305
[
291
306
"git" ,
292
307
"submodule" ,
293
308
"add" ,
294
- "--quiet" ,
295
- "--force" ,
296
309
"--" ,
297
- "./ " ,
310
+ "../deleted_submodule_repo " ,
298
311
"broken_submodule" ,
299
312
],
300
313
cwd = str (broken_repo ),
301
314
)
302
315
316
+ # Assure submodule exists
317
+ gitmodules_file = pathlib .Path (broken_repo ) / ".gitmodules"
318
+ assert gitmodules_file .exists ()
319
+ assert "../deleted_submodule_repo" in gitmodules_file .read_text ()
320
+
321
+ github_projects = user_path / "github_projects"
322
+ broken_repo_checkout = github_projects / "broken_repo"
323
+ assert not broken_repo_checkout .exists ()
324
+
325
+ # Delete the submodule dependency
326
+ shutil .rmtree (deleted_submodule_repo )
327
+ assert not pathlib .Path (deleted_submodule_repo ).exists ()
328
+
303
329
with runner .isolated_filesystem (temp_dir = tmp_path ):
304
330
config = {
305
331
"~/github_projects/" : {
@@ -320,5 +346,7 @@ def test_broken_submodule(
320
346
result = runner .invoke (cli , ["sync" , "broken_repo" ])
321
347
output = "" .join (list (result .output ))
322
348
349
+ assert broken_repo_checkout .exists ()
350
+
323
351
assert "No url found for submodule" == output
324
352
assert result .exit_code == 1
0 commit comments