Skip to content

Commit

Permalink
fixed issue with .git folder (#5)
Browse files Browse the repository at this point in the history
* fixed issue with .git folder

* pre-commit fix

---------

Co-authored-by: Davit Shartava <[email protected]>
  • Loading branch information
dati25 and Davit Shartava authored Jul 30, 2024
1 parent 7cac7a0 commit 3711750
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions project_rossum_deploy/commands/download/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,26 @@ async def should_write_object(path: Path, remote_object: Any, changed_files: lis
return True


def is_within_git_dir(path: Path) -> bool:
"""
Check if the given path is within a .git directory.
"""
for parent in path.parents:
if parent.name == ".git":
return True
return False


def delete_empty_folders(root: Path):
deleted = set()

for current_dir, subdirs, files in os.walk(root, topdown=False):
current_dir_path = Path(current_dir)

# Skip if the current directory is within a .git directory
if is_within_git_dir(current_dir_path):
continue

still_has_subdirs = False
for subdir in subdirs:
if os.path.join(current_dir, subdir) not in deleted:
Expand Down

0 comments on commit 3711750

Please sign in to comment.