Write-tree for listing files
This commit is contained in:
parent
d666efcbd3
commit
73eb89d397
13
ugit/base.py
13
ugit/base.py
|
@ -1 +1,14 @@
|
|||
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 entry.is_file(follow_symlinks=False):
|
||||
# TODO write the file to object store
|
||||
print(full)
|
||||
elif entry.is_dir(follow_symlinks=False):
|
||||
write_tree(full)
|
||||
|
|
|
@ -25,6 +25,9 @@ def parse_args():
|
|||
cat_file_parser.set_defaults(func=cat_file)
|
||||
cat_file_parser.add_argument("object")
|
||||
|
||||
write_tree_parser = commands.add_parser("write-tree")
|
||||
write_tree_parser.set_defaults(func=write_tree)
|
||||
|
||||
hash_object_parser = commands.add_parser("hash-object")
|
||||
hash_object_parser.set_defaults(func=hash_object)
|
||||
hash_object_parser.add_argument("file")
|
||||
|
@ -45,3 +48,7 @@ def hash_object(args):
|
|||
def cat_file(args):
|
||||
sys.stdout.flush()
|
||||
sys.stdout.buffer.write(data.get_object(args.object), expected=None)
|
||||
|
||||
|
||||
def write_tree(args):
|
||||
base.write_tree()
|
||||
|
|
Loading…
Reference in New Issue