diff options
author | glendsoza <gledsouza23@gmail.com> | 2022-01-22 16:55:00 +0530 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-26 09:04:12 +1100 |
commit | 257e222f8d28e8b678ae996f779dc4a4bb76a434 (patch) | |
tree | 4b6ca93b67ae5153e490764a2ad43b67d13eaa5e /pkg/gui | |
parent | 874e230aefb8b7fce1fa99dbeaa9528166c1c788 (diff) |
ISSUE 1706: Ask confirmation before reverting a commit
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index d568caf88..8ba537d6e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -462,21 +462,30 @@ func (gui *Gui) handleCommitPick() error { } func (gui *Gui) handleCommitRevert() error { - if ok, err := gui.validateNotInFilterMode(); err != nil || !ok { - return err - } - commit := gui.getSelectedLocalCommit() + return gui.ask(askOpts{ + title: gui.Tr.Actions.RevertCommit, + prompt: utils.ResolvePlaceholderString( + gui.Tr.ConfirmRevertCommit, + map[string]string{ + "selectedCommit": commit.ShortSha(), + }), + handleConfirm: func() error { + if ok, err := gui.validateNotInFilterMode(); err != nil || !ok { + return err + } - if commit.IsMerge() { - return gui.createRevertMergeCommitMenu(commit) - } else { - gui.logAction(gui.Tr.Actions.RevertCommit) - if err := gui.Git.Commit.Revert(commit.Sha); err != nil { - return gui.surfaceError(err) - } - return gui.afterRevertCommit() - } + if commit.IsMerge() { + return gui.createRevertMergeCommitMenu(commit) + } else { + gui.logAction(gui.Tr.Actions.RevertCommit) + if err := gui.Git.Commit.Revert(commit.Sha); err != nil { + return gui.surfaceError(err) + } + return gui.afterRevertCommit() + } + }, + }) } func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error { |