Skip to content

Commit eb26cfc

Browse files
committed
Fix progress reset on ignore folders
1 parent c54b8f6 commit eb26cfc

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

app/commands/progress/reset.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,27 @@ def reset(ctx: click.Context) -> None:
5252
username = get_username(verbose)
5353
exercise_fork_name = f"{username}-gitmastery-{gitmastery_exercise_config.exercise_repo.repo_title}"
5454
delete_repo(exercise_fork_name, verbose)
55-
rmtree(
55+
56+
if os.path.isdir(
5657
gitmastery_exercise_path / gitmastery_exercise_config.exercise_repo.repo_name
57-
)
58-
setup_exercise_folder(download_time, gitmastery_exercise_config, verbose)
59-
info(
60-
click.style(
61-
f"cd {gitmastery_exercise_config.exercise_repo.repo_name}",
62-
bold=True,
63-
italic=True,
58+
):
59+
# Only delete if the sub-folder present
60+
# Sub-folder may not be present if repo_type is "ignore" or if "ignore" but the
61+
# student has already created the sub-folder needed
62+
rmtree(
63+
gitmastery_exercise_path
64+
/ gitmastery_exercise_config.exercise_repo.repo_name
65+
)
66+
67+
if gitmastery_exercise_config.exercise_repo.repo_type != "ignore":
68+
setup_exercise_folder(download_time, gitmastery_exercise_config, verbose)
69+
info(
70+
click.style(
71+
f"cd {gitmastery_exercise_config.exercise_repo.repo_name}",
72+
bold=True,
73+
italic=True,
74+
)
6475
)
65-
)
6676

6777
if not os.path.isdir(gitmastery_path / LOCAL_FOLDER_NAME):
6878
warn(

0 commit comments

Comments
 (0)