diff options
author | glendsoza <gledsouza23@gmail.com> | 2022-01-24 19:00:26 +0530 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-26 09:04:12 +1100 |
commit | 0caa391c4d6657721aed477cdb2500fef8273cd1 (patch) | |
tree | 811e8747a3bf05f4605624a54f6bdf71656c59e8 /pkg/gui | |
parent | 0c6bdac2f789bb595825dd958a48147e41332e7e (diff) |
Changes as per review
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/commits_panel.go | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 4e3e7b0ad..6b26edc09 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -466,26 +466,25 @@ func (gui *Gui) handleCommitRevert() error { 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 commit.IsMerge() { - return gui.createRevertMergeCommitMenu(commit) - } else { + if commit.IsMerge() { + return gui.createRevertMergeCommitMenu(commit) + } else { + return gui.ask(askOpts{ + title: gui.Tr.Actions.RevertCommit, + prompt: utils.ResolvePlaceholderString( + gui.Tr.ConfirmRevertCommit, + map[string]string{ + "selectedCommit": commit.ShortSha(), + }), + handleConfirm: func() error { 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 { @@ -496,30 +495,16 @@ 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", parentShortSha, message), + displayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message), onPress: func() error { parentNumber := i + 1 gui.logAction(gui.Tr.Actions.RevertCommit) - 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 + if err := gui.Git.Commit.RevertMerge(commit.Sha, parentNumber); err != nil { + return gui.surfaceError(err) + } + return gui.afterRevertCommit() }, } } |