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.
The
seed
command of theodk.py
script is quite fragile, in that it will easily and loudly crash out when it used incorrectly.A) Called with no positional arguments (
odk.py seed
):This causes a crash because the
repo
variable is then set toNone
, while the Jinja template expects a string (or at least something that has aupper()
method):This PR fixes that by setting the
repo
variable tononame
rather thanNone
, resulting in the seeding process successfully creating anoname
repository.B) Called with too many positional arguments (
odk.py seed repo1 repo2
)Only one positional argument is expected. The error condition is correctly caught early, but it still yields an unhelpful stack trace:
We fix that here by raising a
ClickException
rather than a rawException
; Click can intercept those and display only the error message rather than a full stack trace.C) Missing Git username and/or email
Unless
--skipgit
is used, the seeding process needs a Git username and email to pass to Git to create the first commit once the repository is initialised. If for some reason we don’t have a username and/or an email address, this will cause an uncaught exception quite late in the seedingprocess, after all the files have been generated:That error condition should instead be caught early in the script, before even attempting to generate anything. This is what we do here.