From 2b059c4a29516d4cd13ad1ce33390eccf8a02f0c Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Fri, 23 Aug 2024 13:46:22 +0100 Subject: [PATCH] Fail early if we don't have a Git username and email. 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. --- odk/odk.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odk/odk.py b/odk/odk.py index bd5a64e7..df63357f 100755 --- a/odk/odk.py +++ b/odk/odk.py @@ -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)