feat: add --remove-orphaned flag to mani sync command#109
Open
fazzabi wants to merge 2 commits intoalajmo:mainfrom
Open
feat: add --remove-orphaned flag to mani sync command#109fazzabi wants to merge 2 commits intoalajmo:mainfrom
fazzabi wants to merge 2 commits intoalajmo:mainfrom
Conversation
- Add --remove-orphaned flag to sync command for safe cleanup - Add remove_orphaned config option in mani.yaml - Implement git-repository-only detection (improved from directory blacklist approach) - Include user confirmation with preview before deletion - Add comprehensive unit tests and documentation - Only removes directories containing .git folders that aren't in config
Author
|
@alajmo could you please review the PR when you have time? thanks |
alajmo
reviewed
Aug 13, 2025
alajmo
reviewed
Aug 13, 2025
alajmo
reviewed
Aug 13, 2025
- Remove redundant syncFlags.RemoveOrphaned check (comment 1) - Remove unused projects parameter from RemoveOrphanedProjects (comment 2) - Remove test-only removeOrphanedProjectsWithConfirm function (comment 3) - Fix filtering bug: orphaned cleanup now considers all projects, not filtered ones - Simplify function signature and always require user confirmation
Author
|
@alajmo Thank you for the thorough review! I've addressed all three comments in commit 792ad41:
The functionality has been thoroughly tested manually and all existing tests pass. The feature now has a cleaner implementation while maintaining the same safety guarantees and user experience. Ready for re-review! 🚀 |
Author
|
Hi @alajmo ! Just a gentle reminder to review this PR when you have a moment. Let me know if you have any questions or need more details. Thank you! |
Author
|
@alajmo please ⬆️ |
Owner
|
Sorry for late response, just some minor things I've found (I'll be much faster reviewing this time!):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's Changed
This PR implements the
--remove-orphanedflag for themani synccommand, addressing the feature request in issue #108. The implementation provides a safe way to clean up project directories that are no longer defined in the mani configuration.Key Features:
.gitfolders (git repositories)remove_orphaned: truein mani.yaml for permanent enablementExample Usage:
Technical Description
Core Implementation:
os.Stat(filepath.Join(path, ".git"))to identify git repositories, ensuring non-git directories are never removedcore.GetAbsolutePath()for consistent path handling across different project configurationsbufio.NewReader(os.Stdin)for interactive confirmation with clear preview of deletion targetsfmt.Errorf()and graceful failure modesSafety Measures:
Architecture:
RemoveOrphanedProjects()- Public API with confirmationremoveOrphanedProjectsWithConfirm()- Internal function supporting test scenarioscmd/sync.gocore/dao/config.gowith safe defaultsTesting Strategy: