You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm converting some code that is using git.exe reset --hard <short hash> to dulwich. Though porcelain.reset() does support revisions, it does not support short hashes.
I've created my own little helper, since I couldn't find one in dulwich:
def find_sha1(self, short: str | bytes) -> bytes:
if len(short) >= 20:
return short
if isinstance(short, str):
short = short.encode("utf-8")
objs = []
with open_repo_closing(self.repo_dir()) as repo:
for obj in repo.object_store:
if obj[:len(short)] == short:
objs.append(obj)
if not objs:
raise GitException(f"Git object not found: '{short}'")
elif len(objs) != 1:
raise GitException(f"Found multiple Git objects: '{objs}'")
return objs[0]
Thanks a lot
Juergen
The text was updated successfully, but these errors were encountered:
Hi,
I'm converting some code that is using
git.exe reset --hard <short hash>
to dulwich. Thoughporcelain.reset()
does support revisions, it does not support short hashes.I've created my own little helper, since I couldn't find one in dulwich:
Thanks a lot
Juergen
The text was updated successfully, but these errors were encountered: