diff --git a/src/poetry/vcs/git/backend.py b/src/poetry/vcs/git/backend.py index 484eae45285..a9701738038 100644 --- a/src/poetry/vcs/git/backend.py +++ b/src/poetry/vcs/git/backend.py @@ -134,7 +134,9 @@ def is_sha(self) -> bool: @property def is_ref(self) -> bool: - return self.branch is not None and self.branch.startswith("refs/") + return self.branch is not None and ( + self.branch.startswith("refs/") or self.branch == "HEAD" + ) @property def is_sha_short(self) -> bool: diff --git a/tests/integration/test_utils_vcs_git.py b/tests/integration/test_utils_vcs_git.py index 0ee6431d15c..acd1e27ab72 100644 --- a/tests/integration/test_utils_vcs_git.py +++ b/tests/integration/test_utils_vcs_git.py @@ -133,7 +133,11 @@ def test_git_local_info( assert info.revision == remote_refs.refs[remote_default_ref].decode("utf-8") +@pytest.mark.parametrize( + "specification", [{}, {"revision": "HEAD"}, {"branch": "HEAD"}] +) def test_git_clone_default_branch_head( + specification: dict[str, str], source_url: str, remote_refs: FetchPackResult, remote_default_ref: bytes, @@ -142,7 +146,7 @@ def test_git_clone_default_branch_head( spy = mocker.spy(Git, "_clone") spy_legacy = mocker.spy(Git, "_clone_legacy") - with Git.clone(url=source_url) as repo: + with Git.clone(url=source_url, **specification) as repo: assert remote_refs.refs[remote_default_ref] == repo.head() spy_legacy.assert_not_called()