Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/poetry/vcs/git/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 15 additions & 1 deletion tests/integration/test_utils_vcs_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from typing import TYPE_CHECKING
from typing import Iterator
from typing import TypedDict
from urllib.parse import urlparse
from urllib.parse import urlunparse

Expand Down Expand Up @@ -39,6 +40,15 @@
pytestmark = pytest.mark.integration


class GitCloneKwargs(TypedDict):
name: str | None
branch: str | None
tag: str | None
revision: str | None
source_root: Path | None
clean: bool


@pytest.fixture(autouse=True)
def git_mock() -> None:
pass
Expand Down Expand Up @@ -133,7 +143,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: GitCloneKwargs,
source_url: str,
remote_refs: FetchPackResult,
remote_default_ref: bytes,
Expand All @@ -142,7 +156,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()
Expand Down