feat(commits): revert the selected commit from the Commits panel#350
Merged
Conversation
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
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
Adds the ability to revert the selected commit directly from the Commits panel. Press
von a commit and grut confirms the action with the commit subject, then runsgit reverton that hash.Why
The git client already had
Revertplus 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
vin the Commits panel to revert the commit under the cursor.A new
HeadSHAhelper on the git client captures HEAD before the revert so undo has a target.HeadSHAruns first; if it fails, the revert does not run.Testing
HeadSHAand the revert key handler in the commits panel.go build ./...,go vet ./..., lint, deadcode, and gofumpt all clean.v.Closes #340