From 6afb23de04ca2164a4d7b71cd052c23e1ae30c1d Mon Sep 17 00:00:00 2001 From: Arun Babu Neelicattu Date: Sat, 16 Nov 2024 03:46:28 +0100 Subject: [PATCH] vcs: use peeled ref when retrieving tag revision This is required to support incoming changes introduced in dulwich >=0.22.2. This change preserves current behaviour and ensures locks do not change when dulwich is updated. --- src/poetry/vcs/git/backend.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/poetry/vcs/git/backend.py b/src/poetry/vcs/git/backend.py index eddd0efd75e..2764b4fdeee 100644 --- a/src/poetry/vcs/git/backend.py +++ b/src/poetry/vcs/git/backend.py @@ -176,7 +176,7 @@ def get_remote_url(repo: Repo, remote: str = "origin") -> str: @staticmethod def get_revision(repo: Repo) -> str: with repo: - return repo.head().decode("utf-8") + return repo.get_peeled(b"HEAD").decode("utf-8") @classmethod def info(cls, repo: Repo | Path) -> GitRepoLocalInfo: @@ -434,7 +434,8 @@ def clone( current_repo = Repo(str(target)) with current_repo: - current_sha = current_repo.head().decode("utf-8") + # we use peeled sha here to ensure tags are resolved consistently + current_sha = current_repo.get_peeled(b"HEAD").decode("utf-8") except (NotGitRepository, AssertionError, KeyError): # something is wrong with the current checkout, clean it remove_directory(target, force=True)