feat(gitstatus): untracked file cleanup overlay#277
Merged
Conversation
Add an X-triggered cleanup overlay that previews git clean output, supports multi-select, and removes only confirmed paths. Ignored files are opt-in and listed separately. All paths are validated before git. Closes #272 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Add MockClient.Clean/CleanPreview to the deadcode allowlist (interface stubs, matching the existing MockClient block) and extract the keyEscape/keySpace key-name constants so goconst passes now that the cleanup overlay reuses those keys. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
# Conflicts: # magefile.go
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 this does
Adds a cleanup overlay to the Git Status panel for safely removing untracked files. Press
Xto open a preview built fromgit cleandry-run output, multi-select the entries you want gone, then confirm. Only the selected paths are removed. Including ignored files is opt-in and listed separately from plain untracked files.Closes #272
How it works
flowchart TD A[Press X in Git Status] --> B[git clean -nd dry run] B --> C{Include ignored?} C -- yes --> D[git clean -ndX for ignored] C -- no --> E[Untracked only] D --> F[List candidates, ignored marked separately] E --> F F --> G[Multi-select with space] G --> H{Confirm removal?} H -- no --> I[Close, nothing removed] H -- yes --> J[git clean -fd -- selected paths] J --> K[Refresh status and file tree]Changes
internal/git/clean.go:CleanPreviewrunsgit clean -nd(untracked) and, when requested,git clean -ndX(ignored only) so ignored candidates are separated.Cleanrunsgit clean -fd -- <paths>(adds-xwhen ignored are included). Empty path list is a no-op for safety, and every path is validated withValidateRepoRelativePathbefore it reaches git.internal/panels/gitstatus/clean.go: candidate list, multi-select, select-all, cursor, counts, and a confirmation step that reuses the existing destructive-operation prompt.Xregistered in the single source of truth (keybindings.json), mirrored in the panelKeyBindings()and regenerateddocs/keybindings.md.Testing
internal/git: table tests for dry-run parsing plus integration tests against a real repo for preview and remove behavior, including the opt-in ignored path.internal/panels/gitstatus: overlay open/close, selection toggles, select-all, confirm dispatch, and rendering.go build ./...,go vet ./...,gofumpt -lclean.Safety