Generalize HEAD to refs

This commit is contained in:
2024-04-12 17:19:14 +02:00
parent cb8e744794
commit 1f947e6343
3 changed files with 9 additions and 9 deletions

View File

@@ -10,13 +10,13 @@ def init():
Path.mkdir(f"{GIT_DIR}/objects")
def set_HEAD(oid):
with open(f"{GIT_DIR}/HEAD", "w") as f:
def update_ref(ref, oid):
with open(f"{GIT_DIR}/{ref}", "w") as f:
f.write(oid)
def get_HEAD():
if Path.is_file(f"{GIT_DIR}/HEAD"):
def get_ref(ref):
if Path.is_file(f"{GIT_DIR}/{ref}"):
with open(f"{GIT_DIR}/HEAD") as f:
return f.read().strip()