feat: make download comment idempotent and add --force flag - #155
Merged
Conversation
jiaxinnns
requested review from
SAN-MUYUN,
VikramGoyal23,
desmondwong1215 and
jovnc
as code owners
August 28, 2026 09:10
jovnc
approved these changes
Aug 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make
downloadrefuse to overwrite an existing exerciseWhy
gitmastery download <exercise>was silently destructive. If the folder alreadyexisted it printed a
warn()— which only echoes, it doesn't prompt or exit — andthen
rmtree'd the folder. A student re-runninggitmastery d under-controlout ofhabit lost their work with no consent and no recovery (
rmtreetakes a backup butdeletes it on success).
For
remote+create_forkexercises the damage wasn't only local: the re-downloadalso closed the student's open PRs and deleted their GitHub fork.
gitmastery progress resetalready exists as the sanctioned "start over" path, sodownloadhad no reason to also be one.What changed
downloadnow blocks when the target folder exists: it reports that nothing wasdownloaded and points at
progress reset(to start over) or--force(to wipe).Exits 1. The guard runs before any network work, so it's instant.
--force/-fflag opts into the old behaviour. Covers both exercises andhands-on practices, and works in the REPL (
/download <name> --force).Previously
--forcedeleted first and rolled back by deleting again — so a failedcheck left the student with nothing. The base files are staged in a temp dir, the
checks run, and only then is the existing folder replaced.
--forceover a folder with no valid.gitmastery-exercise.json(a partial download, or a folder the student made) raised an unhandled
FileNotFoundError. Now handled via_read_existing_config.Before / after
Note
Behaviour change for anyone scripting a re-download — they'll need
--force.Suggest labelling
bump:minor.