Skip to content

Commit

Permalink
Fix invalid name, email from git config. Fix no information about ski…
Browse files Browse the repository at this point in the history
…pping adding package.
  • Loading branch information
Łukasz Wieczorek committed Jul 3, 2022
1 parent ceb3586 commit fe52e58
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<comment>{author}</comment>, n to skip]: ", default=author
Expand Down Expand Up @@ -281,7 +285,7 @@ def _determine_requirements(
):
self.line(f"Adding <info>{package}</info>")
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"])
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit fe52e58

Please sign in to comment.