Skip to content

feat: allow usage of --prune with --preserve-dir#526

Merged
gabrie30 merged 4 commits intogabrie30:masterfrom
Fraguinha:feat-enable-flag-combo
May 17, 2025
Merged

feat: allow usage of --prune with --preserve-dir#526
gabrie30 merged 4 commits intogabrie30:masterfrom
Fraguinha:feat-enable-flag-combo

Conversation

@Fraguinha
Copy link
Contributor

Status

IN DEVELOPMENT

Description

Adds support for: #445 (allow using both --prune and --preserve-dir flags)

@Fraguinha Fraguinha changed the title feat: allow usage of --prune with --preserve-dir (#521) feat: allow usage of --prune with --preserve-dir May 12, 2025
@gabrie30 gabrie30 marked this pull request as ready for review May 12, 2025 15:22
@gabrie30 gabrie30 marked this pull request as draft May 12, 2025 15:22
@gabrie30
Copy link
Owner

@Fraguinha added you as a contributor, might have an email. But hoping it will fix the issue with the tests running properly

@Fraguinha
Copy link
Contributor Author

I have accepted the invite

about the changes, I have made getRelativePathRepositories return an array of relative paths of repositories within outputDirAbsolutePath

in sliceContainsNamedRepo I also made it compare the repo.Path instead of only it's base

now the prunning logic in the pruneRepos function should be correctly removing the repositories missing from remote with:

os.RemoveAll(filepath.Join(outputDirAbsolutePath, repository))

let me know what you think of the approach, this current version is also no longer segregating the logic between the --preserve-dir --prune and the default behavior that existed previously so if needed I can try and add that back in a follow up commit

@gabrie30
Copy link
Owner

Thanks @Fraguinha I'll take a look when I can

@gabrie30
Copy link
Owner

gabrie30 commented May 15, 2025

The behavior I'm seeing now is that its trying to delete all the repos, I'm running the tests here using the --prune-no-confirm flag. I'll try to take a look this weekend, if you dont get to it before then. Appreciate the efforts, this is a tricky feature.

@Fraguinha
Copy link
Contributor Author

Whoops, my bad, I think I understood why all the repos were being deleted...

repo.Path has a / prefix e.g: /group/group/group/repo while my function returns group/group/group/repo so in sliceContainsNamedRepo the comparison would always fail resulting in all repositories being pruned

I believe now the feature should be working correctly, sorry for the trouble

@gabrie30
Copy link
Owner

Thanks @Fraguinha!

@gabrie30 gabrie30 marked this pull request as ready for review May 17, 2025 15:37
@gabrie30 gabrie30 merged commit 0a2bafb into gabrie30:master May 17, 2025
10 of 13 checks passed
@derekhe
Copy link

derekhe commented Aug 19, 2025

I had a problem using this feature under windows. Seems it deletes everything just cloned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants