diff --git a/src/poetry/core/vcs/git.py b/src/poetry/core/vcs/git.py index 06b8d1940..8fda073bb 100644 --- a/src/poetry/core/vcs/git.py +++ b/src/poetry/core/vcs/git.py @@ -5,7 +5,7 @@ from collections import namedtuple from pathlib import Path -from typing import Any +from typing import Any, Tuple from poetry.core.utils._compat import WINDOWS @@ -255,10 +255,28 @@ def normalize_url(cls, url: str) -> GitUrl: def config(self) -> GitConfig: return self._config + @property + def version(self) -> Tuple[int, int, int]: + output = self.run("version") + version = re.search(r"(\d+)\.(\d+)\.(\d+)", output) + if not version: + return (0, 0, 0) + return int(version.group(1)), int(version.group(2)), int(version.group(3)) + def clone(self, repository: str, dest: Path) -> str: self._check_parameter(repository) - - return self.run("clone", "--recurse-submodules", "--", repository, str(dest)) + cmd = [ + "clone", + "--filter=blob:none", + "--recurse-submodules", + "--", + repository, + str(dest), + ] + # Blobless clones introduced in Git 2.17 + if self.version < (2, 17): + cmd.remove("--filter=blob:none") + return self.run(*cmd) def checkout(self, rev: str, folder: Path | None = None) -> str: args = []