Commit bd583981 by Arun Babu Neelicattu

fix dataclass InitVar usage for git backend

parent edabfce1
......@@ -22,8 +22,6 @@ from poetry.utils.helpers import remove_directory
if TYPE_CHECKING:
from dataclasses import InitVar
from dulwich.client import FetchPackResult
from dulwich.client import GitClient
......@@ -137,7 +135,7 @@ class GitRefSpec:
@dataclasses.dataclass
class GitRepoLocalInfo:
repo: InitVar[Repo | Path | str]
repo: dataclasses.InitVar[Repo | Path | str]
origin: str = dataclasses.field(init=False)
revision: str = dataclasses.field(init=False)
......@@ -157,7 +155,11 @@ class Git:
with repo:
config = repo.get_config()
section = (b"remote", remote.encode("utf-8"))
return config.get(section, b"url") if config.has_section(section) else ""
return (
config.get(section, b"url").decode("utf-8")
if config.has_section(section)
else ""
)
@staticmethod
def get_revision(repo: Repo) -> str:
......
......@@ -108,6 +108,15 @@ def remote_default_branch(remote_default_ref: bytes) -> str:
return remote_default_ref.decode("utf-8").replace("refs/heads/", "")
def test_git_local_info(
source_url: str, remote_refs: FetchPackResult, remote_default_ref: bytes
) -> None:
with Git.clone(url=source_url) as repo:
info = Git.info(repo=repo)
assert info.origin == source_url
assert info.revision == remote_refs.refs[remote_default_ref].decode("utf-8")
def test_git_clone_default_branch_head(
source_url: str,
remote_refs: FetchPackResult,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment