From 0c6bdac2f789bb595825dd958a48147e41332e7e Mon Sep 17 00:00:00 2001 From: glendsoza Date: Sun, 23 Jan 2022 13:16:21 +0530 Subject: Changes as per review --- pkg/gui/commits_panel.go | 32 +++++++++++++++++++++++--------- pkg/i18n/english.go | 2 +- 2 files changed, 24 insertions(+), 10 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 }, } } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 8b421de08..5f03881a6 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1028,7 +1028,7 @@ func EnglishTranslationSet() TranslationSet { CantChangeContextSizeError: "Cannot change context while in patch building mode because we were too lazy to support it when releasing the feature. If you really want it, please let us know!", LcOpenCommitInBrowser: "open commit in browser", LcViewBisectOptions: "view bisect options", - ConfirmRevertCommit: "Are you sure you want to revert {{.selectedCommit}}? ", + ConfirmRevertCommit: "Are you sure you want to revert {{.selectedCommit}}?", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) CheckoutCommit: "Checkout commit", -- cgit v1.2.3