Save hash object
This commit is contained in:
10
ugit/data.py
10
ugit/data.py
@@ -1,7 +1,17 @@
|
||||
from pathlib import Path
|
||||
|
||||
import hashlib
|
||||
|
||||
GIT_DIR = ".ugit"
|
||||
|
||||
|
||||
def init():
|
||||
Path.mkdir(GIT_DIR)
|
||||
Path.mkdir(f"{GIT_DIR}/objects")
|
||||
|
||||
|
||||
def hash_object(data):
|
||||
oid = hashlib.sha1(data).hexdigest()
|
||||
with open(f"{GIT_DIR}/objects/{oid}", "wb") as out:
|
||||
out.write(data)
|
||||
return oid
|
||||
|
||||
Reference in New Issue
Block a user