From b0314d645815b48c27cccea861fa70bc890a829c Mon Sep 17 00:00:00 2001 From: Bartosz Sokorski Date: Thu, 23 Oct 2025 13:44:55 +0200 Subject: [PATCH] Switch init pyproject to dulwich --- src/poetry/console/commands/init.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index 48ea6e206ed..d463271ea1a 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -91,7 +91,7 @@ def _init_pyproject( readme_format: str = "md", allow_layout_creation_on_empty: bool = False, ) -> int: - from poetry.core.vcs.git import GitConfig + from dulwich.config import StackedConfig from poetry.config.config import Config from poetry.layouts import layout @@ -116,8 +116,6 @@ def _init_pyproject( ) return 1 - vcs_config = GitConfig() - if is_interactive: self.line("") self.line( @@ -148,11 +146,19 @@ def _init_pyproject( if not description and is_interactive: description = self.ask(self.create_question("Description []: ", default="")) + vcs_config = StackedConfig.default() + + def get_vcs_config_value(*keys: str) -> str | None: + try: + value = str(vcs_config.get(*keys)) + except KeyError: + value = None + return value + author = self.option("author") - if not author and vcs_config.get("user.name"): - author = vcs_config["user.name"] - author_email = vcs_config.get("user.email") - if author_email: + if not author and (vcs_username := get_vcs_config_value("user", "name")): + author = vcs_username + if author_email := get_vcs_config_value("user", "email"): author += f" <{author_email}>" if is_interactive: