18 lines
296 B
Python
18 lines
296 B
Python
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
|