Skip to content

Commit

Permalink
Fail early if we don't have a Git username and email.
Browse files Browse the repository at this point in the history
When seeding, and unless the --skipgit option has been used, we need a
username and email address to pass to Git. If we don't have those, the
seeding process will crash at the very end, after all files have been
generated.

Since the Git username and email are necessary, we should detect whether
we have them at the very beginning, and exit cleanly (with a message
telling the user what they need to to) as soon as possible, without even
initiating a process that is bound to fail.
  • Loading branch information
gouttegd committed Aug 23, 2024
1 parent fedb542 commit 2b059c4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions odk/odk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,11 @@ def seed(config, clean, outdir, templatedir, dependencies, title, user, source,
project.id = repo
if outdir is None:
outdir = "target/{}".format(project.id)
if not skipgit:
if not "GIT_AUTHOR_NAME" in os.environ and not gitname:
raise click.ClickException("missing Git username; set GIT_AUTHOR_NAME or use --gitname")
if not "GIT_AUTHOR_EMAIL" in os.environ and not gitemail:
raise click.ClickException("missing Git email; set GIT_AUTHOR_EMAIL or use --gitemail")
if clean:
if os.path.exists(outdir):
shutil.rmtree(outdir)
Expand Down

0 comments on commit 2b059c4

Please sign in to comment.