Record hash of last commit

This commit is contained in:
2024-03-13 19:38:35 +01:00
parent 6a91c03f40
commit 1847cfbb17
2 changed files with 10 additions and 1 deletions

View File

@@ -10,6 +10,11 @@ def init():
Path.mkdir(f"{GIT_DIR}/objects")
def set_HEAD(oid):
with open(f"{GIT_DIR}/HEAD", "w") as f:
f.write(oid)
def hash_object(data, type_="blob"):
obj = type_.encode() + b"\x00" + data
oid = hashlib.sha1(obj).hexdigest()