Skip to content

feat(gitstatus): untracked file cleanup overlay#277

Merged
jongio merged 3 commits into
mainfrom
idea/git-clean-preview
Jul 7, 2026
Merged

feat(gitstatus): untracked file cleanup overlay#277
jongio merged 3 commits into
mainfrom
idea/git-clean-preview

Conversation

@jongio

@jongio jongio commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What this does

Adds a cleanup overlay to the Git Status panel for safely removing untracked files. Press X to open a preview built from git clean dry-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]
Loading

Changes

  • New internal/git/clean.go: CleanPreview runs git clean -nd (untracked) and, when requested, git clean -ndX (ignored only) so ignored candidates are separated. Clean runs git clean -fd -- <paths> (adds -x when ignored are included). Empty path list is a no-op for safety, and every path is validated with ValidateRepoRelativePath before it reaches git.
  • Dry-run output is parsed under a forced C locale so the "Would remove" prefix is stable across languages.
  • New cleanup overlay in internal/panels/gitstatus/clean.go: candidate list, multi-select, select-all, cursor, counts, and a confirmation step that reuses the existing destructive-operation prompt.
  • Keybinding X registered in the single source of truth (keybindings.json), mirrored in the panel KeyBindings() and regenerated docs/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 -l clean.

Safety

  • Nothing is removed without explicit confirmation.
  • Removal is scoped to the exact selected paths; no selection means no operation.
  • Ignored files require an explicit opt-in and are visually separated from untracked files.
  • All paths are validated before being passed to git.

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>
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 5, 2026
@jongio jongio self-assigned this Jul 5, 2026
jongio and others added 2 commits July 6, 2026 18:01
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>
@jongio jongio merged commit 72dc5c4 into main Jul 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

idea Feature idea from the idea pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview and selectively remove untracked files with a git clean dry run

1 participant