2024-02-26 18:59:58 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
2024-02-21 20:46:59 +01:00
|
|
|
from . import data
|
2024-02-26 18:59:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
def write_tree(directory="."):
|
|
|
|
with Path.iterdir(directory) as it:
|
|
|
|
for entry in it:
|
|
|
|
full = f"{directory}/{entry.name}"
|
2024-02-28 19:45:34 +01:00
|
|
|
if is_ignored(full):
|
|
|
|
continue
|
2024-02-26 18:59:58 +01:00
|
|
|
if entry.is_file(follow_symlinks=False):
|
2024-02-28 19:51:24 +01:00
|
|
|
with open(full, "rb") as f:
|
|
|
|
print(data.hash_object(f.read()), full)
|
2024-02-26 18:59:58 +01:00
|
|
|
elif entry.is_dir(follow_symlinks=False):
|
|
|
|
write_tree(full)
|
2024-02-28 19:45:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
def is_ignored(path):
|
|
|
|
return ".ugit" in path.split("/")
|