@@ -189,44 +189,70 @@ def test_sync_broken(
189
189
190
190
# @pytest.mark.skip("No recreation yet, #366")
191
191
def test_broken_submodule (
192
- home_path : pathlib .Path ,
192
+ user_path : pathlib .Path ,
193
193
config_path : pathlib .Path ,
194
194
tmp_path : pathlib .Path ,
195
195
git_repo : GitSync ,
196
196
create_git_dummy_repo : DummyRepoProtocol ,
197
197
) -> None :
198
198
runner = CliRunner ()
199
199
200
+ deleted_submodule_repo = create_git_dummy_repo (
201
+ repo_name = "deleted_submodule_repo" , testfile_filename = "dummy_file.txt"
202
+ )
203
+
200
204
broken_repo = create_git_dummy_repo (
201
205
repo_name = "broken_repo" , testfile_filename = "dummy_file.txt"
202
206
)
203
207
204
208
# Try to recreated gitmodules by hand
205
209
206
210
# 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
212
216
# """,
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
+ # )
215
230
216
231
run (
217
232
[
218
233
"git" ,
219
234
"submodule" ,
220
235
"add" ,
221
- "--quiet" ,
222
- "--force" ,
223
236
"--" ,
224
- "./ " ,
237
+ "../deleted_submodule_repo " ,
225
238
"broken_submodule" ,
226
239
],
227
240
cwd = str (broken_repo ),
228
241
)
229
242
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
+
230
256
with runner .isolated_filesystem (temp_dir = tmp_path ):
231
257
config = {
232
258
"~/github_projects/" : {
@@ -247,5 +273,7 @@ def test_broken_submodule(
247
273
result = runner .invoke (cli , ["sync" , "broken_repo" ])
248
274
output = "" .join (list (result .output ))
249
275
276
+ assert broken_repo_checkout .exists ()
277
+
250
278
assert "No url found for submodule" == output
251
279
assert result .exit_code == 1
0 commit comments