Skip to content

Commit

Permalink
fixed issue with .git folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Davit Shartava committed Jul 24, 2024
1 parent 7cac7a0 commit 135d094
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 135d094

Please sign in to comment.