Skip to content

feat(commits): revert the selected commit from the Commits panel#350

Merged
jongio merged 2 commits into
mainfrom
idea/commits-revert
Jul 21, 2026
Merged

feat(commits): revert the selected commit from the Commits panel#350
jongio merged 2 commits into
mainfrom
idea/commits-revert

Conversation

@jongio

@jongio jongio commented Jul 19, 2026

Copy link
Copy Markdown
Owner

What

Adds the ability to revert the selected commit directly from the Commits panel. Press v on a commit and grut confirms the action with the commit subject, then runs git revert on that hash.

Why

The git client already had Revert plus undo and redo revert handlers, but nothing in the UI called them. This wires that existing capability to a key so you can revert without dropping to a shell.

How it works

  • Press v in the Commits panel to revert the commit under the cursor.
  • A confirm prompt shows the commit subject before anything runs.
  • On confirm, grut captures HEAD, runs the revert, then reloads commits, branches, and status.
  • The revert is undoable: undo resets HEAD back to where it was before the revert, redo re-applies it.

A new HeadSHA helper on the git client captures HEAD before the revert so undo has a target. HeadSHA runs first; if it fails, the revert does not run.

Testing

  • Unit tests for HeadSHA and the revert key handler in the commits panel.
  • TUI handler tests covering the confirm flow, async execution, the HeadSHA-before-revert ordering, error paths, and the post-revert reload.
  • go build ./..., go vet ./..., lint, deadcode, and gofumpt all clean.
  • Keybindings JSON and generated docs updated to include v.

Closes #340

Press v on a commit in the Commits panel to revert it. grut shows a
confirm prompt with the commit subject, then runs git revert on the
selected hash and reloads the commits, branches, and status views.

The revert is recorded as an undoable action: undo resets HEAD back to
where it was before the revert, and redo re-applies it. This reuses the
existing git.Client.Revert plus the undo and redo revert handlers that
were already in place but not wired to the UI.

Adds a HeadSHA helper on the git client so the undo action can capture
HEAD before the revert runs. HeadSHA runs first; if it fails, the revert
does not run.

Closes #340

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 07f6eb49-d72f-4f2a-9285-065b5d835f5b
@jongio jongio added the idea Feature idea from the idea pipeline label Jul 19, 2026
@jongio jongio self-assigned this Jul 19, 2026
@jongio
jongio merged commit 79ffb37 into main Jul 21, 2026
@jongio
jongio deleted the idea/commits-revert branch July 21, 2026 18:40
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.

Revert the selected commit from the Commits panel

1 participant