diff options
author | glendsoza <gledsouza23@gmail.com> | 2022-01-23 13:16:21 +0530 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-26 09:04:12 +1100 |
commit | 0c6bdac2f789bb595825dd958a48147e41332e7e (patch) | |
tree | c2981013420a2d39c343d52d2429184c65538106 /pkg/gui | |
parent | 257e222f8d28e8b678ae996f779dc4a4bb76a434 (diff) |
Changes as per review
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 8ba537d6e..4e3e7b0ad 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -462,6 +462,9 @@ 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, @@ -471,9 +474,6 @@ func (gui *Gui) handleCommitRevert() error { "selectedCommit": commit.ShortSha(), }), handleConfirm: func() error { - if ok, err := gui.validateNotInFilterMode(); err != nil || !ok { - return err - } if commit.IsMerge() { return gui.createRevertMergeCommitMenu(commit) @@ -496,16 +496,30 @@ func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error { if err != nil { return gui.surfaceError(err) } - + parentShortSha := utils.SafeTruncate(parentSha, 8) menuItems[i] = &menuItem{ - displayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message), + displayString: fmt.Sprintf("%s: %s", parentShortSha, message), onPress: func() error { parentNumber := i + 1 gui.logAction(gui.Tr.Actions.RevertCommit) - if err := gui.Git.Commit.RevertMerge(commit.Sha, parentNumber); err != nil { - return gui.surfaceError(err) - } - return gui.afterRevertCommit() + gui.ask(askOpts{ + title: gui.Tr.SelectParentCommitForMerge, + prompt: utils.ResolvePlaceholderString( + "Are you sure you want use {{.selectedParentCommit}} as parent commit?", + map[string]string{ + "selectedParentCommit": parentShortSha, + }), + handleConfirm: func() error { + if err := gui.Git.Commit.RevertMerge(commit.Sha, parentNumber); err != nil { + return gui.surfaceError(err) + } + return gui.afterRevertCommit() + }, + handleClose: func() error { + return gui.pushContext(gui.State.Contexts.Menu) + }, + }) + return nil }, } } |