Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue with .git folder #5

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading