Skip to content

Commit

Permalink
dulwich: add ls-remote to list remote repository
Browse files Browse the repository at this point in the history
Closes #321.
  • Loading branch information
skshetry committed Feb 7, 2024
1 parent 6854f0d commit 99715fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/scmrepo/git/backend/dulwich/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,3 +978,17 @@ def _parse_identity(identity: str) -> tuple[str, str]:
if not m:
raise SCMError("Could not parse tagger identity '{identity}'")
return m.group("name"), m.group("email")


def ls_remote(url: str) -> dict[str, str]:
from dulwich.client import HTTPUnauthorized
from dulwich.porcelain import ls_remote

try:
return {
os.fsdecode(ref): sha.decode("ascii") for ref, sha in ls_remote(url).items()
}
except HTTPUnauthorized as exc:
raise AuthError(url) from exc
except Exception as exc: # noqa: BLE001
raise InvalidRemote(url) from exc

0 comments on commit 99715fa

Please sign in to comment.