Compare commits

...

2 Commits

Author SHA1 Message Date
David Doblas Jiménez 46a20c8b60 Write-tree ignore .ugit files 2024-02-28 19:45:34 +01:00
David Doblas Jiménez fdfcfdbdad Add change 09 instructions 2024-02-28 19:44:10 +01:00
2 changed files with 14 additions and 0 deletions

8
how_to/Change_09.md Normal file
View File

@ -0,0 +1,8 @@
- write-tree: Ignore .ugit files
If we run `ugit write-tree`, we will see that it also prints the content of the
.ugit directory. This directory isn't part of the user's files, so let's ignore
it.
Actually, I created a separate `is_ignored()` function. This way if we have any
other files we want to ignore later we have one place to change.

View File

@ -7,8 +7,14 @@ 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):
# TODO write the file to object store
print(full)
elif entry.is_dir(follow_symlinks=False):
write_tree(full)
def is_ignored(path):
return ".ugit" in path.split("/")