diff --git a/src/poetry/vcs/git/backend.py b/src/poetry/vcs/git/backend.py index eddd0efd75e..da0b58db68f 100644 --- a/src/poetry/vcs/git/backend.py +++ b/src/poetry/vcs/git/backend.py @@ -231,11 +231,8 @@ def _clone_legacy(url: str, refspec: GitRefSpec, target: Path) -> Repo: try: SystemGit.clone(url, target) - except CalledProcessError: - raise PoetryConsoleError( - f"Failed to clone {url}, check your git configuration and permissions" - " for this repository." - ) + except CalledProcessError as e: + raise PoetryConsoleError(f"Failed to clone {url}\n {e.stderr}") if revision: revision.replace("refs/head/", "") diff --git a/src/poetry/vcs/git/system.py b/src/poetry/vcs/git/system.py index 27ab0330002..f994d677faf 100644 --- a/src/poetry/vcs/git/system.py +++ b/src/poetry/vcs/git/system.py @@ -40,10 +40,10 @@ def run(*args: Any, **kwargs: Any) -> None: git_command = find_git_command() env = os.environ.copy() env["GIT_TERMINAL_PROMPT"] = "0" - subprocess.check_call( # type: ignore[call-arg] + subprocess.run( git_command + list(args), - stderr=subprocess.DEVNULL, - stdout=subprocess.DEVNULL, + check=True, + capture_output=True, env=env, text=True, encoding="utf-8", diff --git a/tests/integration/test_utils_vcs_git.py b/tests/integration/test_utils_vcs_git.py index 1e4229e0f48..15cd5922b0f 100644 --- a/tests/integration/test_utils_vcs_git.py +++ b/tests/integration/test_utils_vcs_git.py @@ -435,3 +435,13 @@ def test_relative_submodules_with_ssh( "ssh://github.com/python-poetry/test-fixture-vcs-repository.git", "ssh://github.com/python-poetry/test-fixture-vcs-repository.git", ] + + +def test_git_error_is_exposed_for_non_existent_repo() -> None: + source_url = "https://github.com/python-poetry/test-fixture-vcs-repo.git" + branch = uuid.uuid4().hex + + with pytest.raises(PoetryConsoleError) as e: + Git.clone(url=source_url, branch=branch) + + assert "remote: Repository not found." in str(e.value)