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 | |
parent | 874e230aefb8b7fce1fa99dbeaa9528166c1c788 (diff) |
ISSUE 1706: Ask confirmation before reverting a commit
-rw-r--r-- | pkg/gui/commits_panel.go | 35 | ||||
-rw-r--r-- | pkg/i18n/chinese.go | 1 | ||||
-rw-r--r-- | pkg/i18n/dutch.go | 1 | ||||
-rw-r--r-- | pkg/i18n/english.go | 2 | ||||
-rw-r--r-- | pkg/i18n/polish.go | 1 |
5 files changed, 27 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 { diff --git a/pkg/i18n/chinese.go b/pkg/i18n/chinese.go index 585d77b38..4843dc149 100644 --- a/pkg/i18n/chinese.go +++ b/pkg/i18n/chinese.go @@ -438,6 +438,7 @@ func chineseTranslationSet() TranslationSet { LcCreatePullRequestOptions: "创建抓取请求选项", LcDefaultBranch: "默认分支", LcSelectBranch: "选择分支", + ConfirmRevertCommit: "您确定要撤消 {{.selectedCommit}} 吗?", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) CheckoutCommit: "检出提交", diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 7e8b2dcec..3e9989a6a 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -362,5 +362,6 @@ func dutchTranslationSet() TranslationSet { LcViewStashFiles: "bekijk bestanden van stash entry", CreatePullRequestOptions: "Bekijk opties voor pull-aanvraag", LcCreatePullRequestOptions: "bekijk opties voor pull-aanvraag", + ConfirmRevertCommit: "Weet u zeker dat u {{.selectedCommit}} ongedaan wilt maken?", } } diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 8899cc6fc..8b421de08 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -454,6 +454,7 @@ type TranslationSet struct { CantChangeContextSizeError string LcOpenCommitInBrowser string LcViewBisectOptions string + ConfirmRevertCommit string Actions Actions Bisect Bisect } @@ -1027,6 +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}}? ", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) CheckoutCommit: "Checkout commit", diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index f378fa08b..13313a165 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -229,5 +229,6 @@ func polishTranslationSet() TranslationSet { LcCopiedToClipboard: "skopiowany do schowka", CreatePullRequestOptions: "Utwórz opcje żądania ściągnięcia", LcCreatePullRequestOptions: "utwórz opcje żądania ściągnięcia", + ConfirmRevertCommit: "Czy na pewno chcesz obrócić {{.selectedCommit}}?", } } |