-
-
Notifications
You must be signed in to change notification settings - Fork 33
feat: add --remove-orphaned flag to mani sync command #109
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
base: main
Are you sure you want to change the base?
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
|
@alajmo could you please review the PR when you have time? thanks |
- 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
|
@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! 🚀 |
|
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! |
|
@alajmo please ⬆️ |
|
Sorry for late response, just some minor things I've found (I'll be much faster reviewing this time!):
|
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: