mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-24 08:52:21 +02:00
ISSUE 1706: Ask confirmation before reverting a commit
This commit is contained in:
parent
874e230aef
commit
257e222f8d
@ -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 {
|
||||
|
@ -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: "检出提交",
|
||||
|
@ -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?",
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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}}?",
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user