feat: add history tracking, undo/redo, and cross-platform trash management#379
feat: add history tracking, undo/redo, and cross-platform trash management#379nicholas-fedor merged 3 commits intomainfrom
Conversation
- Add trash management with platform-specific implementations - Implement history tracking for operation logging - Create storage layer for persistent data management - Add build info extraction for version metadata - Establish integration testing framework with mocks
- Add Darwin (macOS) and riscv64 architecture support to release builds - Improve version detection and install command generation from build info - Refactor collision detection in history manager to use direct filesystem checks - Extend storage schema with ReinstallCommand for accurate binary restoration - Fix test instability issues and remove deprecated --version CLI flag
- Refactor getStoragePath() to verify directory writability with fallback chain - Add isDirWritable() helper to test permissions via temp file creation - Return errors from getStoragePath() for proper error handling - Preserve symlinks during directory copying using Lstat instead of Stat - Exclude darwin/riscv64 from goreleaser builds
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (47)
WalkthroughThis PR introduces a complete deletion history and restoration system, featuring platform-specific trash handling, persistent storage via Badger database, build-info extraction from Go binaries, and corresponding CLI/TUI integration with undo and restore commands. The changes span workflow configuration, dependency management, multiple new internal subsystems, comprehensive test coverage, and documentation updates. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Root<br/>Command
participant HistMgr as History<br/>Manager
participant Extractor
participant Trash
participant Storage
participant Logger
User->>CLI: go-remove <binary>
activate CLI
CLI->>HistMgr: RecordDeletion(ctx, path)
activate HistMgr
HistMgr->>Extractor: Extract(ctx, path)
activate Extractor
Extractor-->>HistMgr: BuildInfoData
deactivate Extractor
HistMgr->>Extractor: CalculateChecksum(path)
activate Extractor
Extractor-->>HistMgr: checksum
deactivate Extractor
HistMgr->>Trash: MoveToTrash(ctx, path)
activate Trash
Trash-->>HistMgr: trashPath
deactivate Trash
HistMgr->>Storage: SaveRecord(ctx, record)
activate Storage
Storage-->>HistMgr: success
deactivate Storage
HistMgr->>Logger: Log success
HistMgr-->>CLI: HistoryEntry
deactivate HistMgr
CLI->>User: Success message
deactivate CLI
sequenceDiagram
participant User
participant CLI as Root<br/>Command
participant TUI
participant HistMgr as History<br/>Manager
participant Storage
participant Trash
User->>CLI: go-remove --restore
activate CLI
CLI->>TUI: RunTUI(..., historyMgr)
activate TUI
TUI->>HistMgr: GetHistory(ctx)
activate HistMgr
HistMgr->>Storage: ListRecords(ctx)
activate Storage
Storage-->>HistMgr: records
deactivate Storage
HistMgr-->>TUI: entries
deactivate HistMgr
TUI->>User: Display history
Note over User,TUI: User selects entry
User->>TUI: Select entry + restore
activate TUI
TUI->>HistMgr: Restore(ctx, entryID)
activate HistMgr
HistMgr->>Storage: GetRecord(ctx, key)
activate Storage
Storage-->>HistMgr: record
deactivate Storage
HistMgr->>Trash: RestoreFromTrash(ctx, trashPath)
activate Trash
Trash-->>HistMgr: success
deactivate Trash
HistMgr->>Storage: UpdateRecord(ctx)
activate Storage
Storage-->>HistMgr: success
deactivate Storage
HistMgr-->>TUI: RestoreResult
deactivate HistMgr
TUI->>User: Restore complete
deactivate TUI
deactivate CLI
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
gosec found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
This PR transforms go-remove from a simple file removal tool into a comprehensive Go binary management utility with full history tracking, undo/redo capabilities, and cross-platform trash support. All removals are now tracked with metadata (module path, version, VCS revision, checksums) and can be restored from trash when needed.
Problem
The existing go-remove tool provided only basic file removal without any safety mechanisms or recovery options. Users had no way to:
Solution
Implement a complete history management system with persistent storage, cross-platform trash handling, and an enhanced TUI for browsing and restoring removed binaries. The solution captures build information from Go binaries before removal, stores records in BadgerDB, and moves files to system trash (XDG on Linux, Recycle Bin on Windows) for safe recovery.
Changes
Summary by CodeRabbit
New Features
--undoand--restorefor command-line workflowsDocumentation
Build