21 lines
554 B
Python
21 lines
554 B
Python
from pathlib import Path
|
|
|
|
from . import data
|
|
|
|
|
|
def write_tree(directory="."):
|
|
with Path.iterdir(directory) as it:
|
|
for entry in it:
|
|
full = f"{directory}/{entry.name}"
|
|
if is_ignored(full):
|
|
continue
|
|
if entry.is_file(follow_symlinks=False):
|
|
with open(full, "rb") as f:
|
|
print(data.hash_object(f.read()), full)
|
|
elif entry.is_dir(follow_symlinks=False):
|
|
write_tree(full)
|
|
|
|
|
|
def is_ignored(path):
|
|
return ".ugit" in path.split("/")
|