Create the tag ref
This commit is contained in:
parent
e85766f671
commit
edae32dc86
|
@ -96,6 +96,8 @@ def commit(message):
|
||||||
|
|
||||||
return oid
|
return oid
|
||||||
|
|
||||||
|
def create_tag(name, oid):
|
||||||
|
data.update_ref(f"refs/tags/{name}", oid)
|
||||||
|
|
||||||
def checkout(oid):
|
def checkout(oid):
|
||||||
commit = get_commit(oid)
|
commit = get_commit(oid)
|
||||||
|
|
|
@ -11,13 +11,16 @@ def init():
|
||||||
|
|
||||||
|
|
||||||
def update_ref(ref, oid):
|
def update_ref(ref, oid):
|
||||||
with open(f"{GIT_DIR}/{ref}", "w") as f:
|
ref_path = f"{GIT_DIR}/{ref}"
|
||||||
|
Path.mkdir(ref_path, exist_ok=True)
|
||||||
|
with open(ref_path, "w") as f:
|
||||||
f.write(oid)
|
f.write(oid)
|
||||||
|
|
||||||
|
|
||||||
def get_ref(ref):
|
def get_ref(ref):
|
||||||
if Path.is_file(f"{GIT_DIR}/{ref}"):
|
ref_path = f"{GIT_DIR}/{ref}"
|
||||||
with open(f"{GIT_DIR}/HEAD") as f:
|
if Path.is_file(ref_path):
|
||||||
|
with open(ref_path) as f:
|
||||||
return f.read().strip()
|
return f.read().strip()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue