From fe52e584828a39082e13dd66b4a3b17080ed5456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Wieczorek?= Date: Sun, 3 Jul 2022 14:39:13 +0200 Subject: [PATCH] Fix invalid name, email from git config. Fix no information about skipping adding package. --- src/poetry/console/commands/init.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index 5501624c22f..58971171f18 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -122,12 +122,16 @@ def handle(self) -> int: if not description: description = self.ask(self.create_question("Description []: ", default="")) + def strip(string): + """Strings from VCS config come with apostrophes.""" + return string.lstrip("'").rstrip("'") + author = self.option("author") if not author and vcs_config.get("user.name"): - author = vcs_config["user.name"] + author = strip(vcs_config["user.name"]) author_email = vcs_config.get("user.email") if author_email: - author += f" <{author_email}>" + author += f" <{strip(author_email)}>" question = self.create_question( f"Author [{author}, n to skip]: ", default=author @@ -281,7 +285,7 @@ def _determine_requirements( ): self.line(f"Adding {package}") result.append(constraint) - package = self.ask("\nAdd a package:") + package = self.ask("\nAdd a package (leave blank to skip):") continue canonicalized_name = canonicalize_name(constraint["name"]) @@ -347,7 +351,7 @@ def _determine_requirements( result.append(constraint) if self.io.is_interactive(): - package = self.ask("\nAdd a package:") + package = self.ask("\nAdd a package (leave blank to skip):") return result