Record hash of last commit
This commit is contained in:
@@ -81,7 +81,11 @@ def commit(message):
|
|||||||
commit += "\n"
|
commit += "\n"
|
||||||
commit += f"{message}\n"
|
commit += f"{message}\n"
|
||||||
|
|
||||||
return data.hash_object(commit.encode(), "commit")
|
oid = data.hash_object(commit.encode(), "commit")
|
||||||
|
|
||||||
|
data.set_HEAD(oid)
|
||||||
|
|
||||||
|
return oid
|
||||||
|
|
||||||
|
|
||||||
def is_ignored(path):
|
def is_ignored(path):
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ def init():
|
|||||||
Path.mkdir(f"{GIT_DIR}/objects")
|
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"):
|
def hash_object(data, type_="blob"):
|
||||||
obj = type_.encode() + b"\x00" + data
|
obj = type_.encode() + b"\x00" + data
|
||||||
oid = hashlib.sha1(obj).hexdigest()
|
oid = hashlib.sha1(obj).hexdigest()
|
||||||
|
|||||||
Reference in New Issue
Block a user