Skip to content

Commit 454a522

Browse files
authored
dulwich: add ls-remote to list remote repository (#322)
Closes #321.
1 parent 6854f0d commit 454a522

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/scmrepo/git/backend/dulwich/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -978,3 +978,16 @@ def _parse_identity(identity: str) -> tuple[str, str]:
978978
if not m:
979979
raise SCMError("Could not parse tagger identity '{identity}'")
980980
return m.group("name"), m.group("email")
981+
982+
983+
def ls_remote(url: str) -> dict[str, str]:
984+
from dulwich import porcelain
985+
from dulwich.client import HTTPUnauthorized
986+
987+
try:
988+
refs = porcelain.ls_remote(url)
989+
return {os.fsdecode(ref): sha.decode("ascii") for ref, sha in refs.items()}
990+
except HTTPUnauthorized as exc:
991+
raise AuthError(url) from exc
992+
except Exception as exc: # noqa: BLE001
993+
raise InvalidRemote(url) from exc

0 commit comments

Comments
 (0)