mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-25 12:24:47 +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 {
|
func (gui *Gui) handleCommitRevert() error {
|
||||||
if ok, err := gui.validateNotInFilterMode(); err != nil || !ok {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
commit := gui.getSelectedLocalCommit()
|
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() {
|
if commit.IsMerge() {
|
||||||
return gui.createRevertMergeCommitMenu(commit)
|
return gui.createRevertMergeCommitMenu(commit)
|
||||||
} else {
|
} else {
|
||||||
gui.logAction(gui.Tr.Actions.RevertCommit)
|
gui.logAction(gui.Tr.Actions.RevertCommit)
|
||||||
if err := gui.Git.Commit.Revert(commit.Sha); err != nil {
|
if err := gui.Git.Commit.Revert(commit.Sha); err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
return gui.afterRevertCommit()
|
return gui.afterRevertCommit()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error {
|
func (gui *Gui) createRevertMergeCommitMenu(commit *models.Commit) error {
|
||||||
|
@ -438,6 +438,7 @@ func chineseTranslationSet() TranslationSet {
|
|||||||
LcCreatePullRequestOptions: "创建抓取请求选项",
|
LcCreatePullRequestOptions: "创建抓取请求选项",
|
||||||
LcDefaultBranch: "默认分支",
|
LcDefaultBranch: "默认分支",
|
||||||
LcSelectBranch: "选择分支",
|
LcSelectBranch: "选择分支",
|
||||||
|
ConfirmRevertCommit: "您确定要撤消 {{.selectedCommit}} 吗?",
|
||||||
Actions: Actions{
|
Actions: Actions{
|
||||||
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
||||||
CheckoutCommit: "检出提交",
|
CheckoutCommit: "检出提交",
|
||||||
|
@ -362,5 +362,6 @@ func dutchTranslationSet() TranslationSet {
|
|||||||
LcViewStashFiles: "bekijk bestanden van stash entry",
|
LcViewStashFiles: "bekijk bestanden van stash entry",
|
||||||
CreatePullRequestOptions: "Bekijk opties voor pull-aanvraag",
|
CreatePullRequestOptions: "Bekijk opties voor pull-aanvraag",
|
||||||
LcCreatePullRequestOptions: "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
|
CantChangeContextSizeError string
|
||||||
LcOpenCommitInBrowser string
|
LcOpenCommitInBrowser string
|
||||||
LcViewBisectOptions string
|
LcViewBisectOptions string
|
||||||
|
ConfirmRevertCommit string
|
||||||
Actions Actions
|
Actions Actions
|
||||||
Bisect Bisect
|
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!",
|
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",
|
LcOpenCommitInBrowser: "open commit in browser",
|
||||||
LcViewBisectOptions: "view bisect options",
|
LcViewBisectOptions: "view bisect options",
|
||||||
|
ConfirmRevertCommit: "Are you sure you want to revert {{.selectedCommit}}? ",
|
||||||
Actions: Actions{
|
Actions: Actions{
|
||||||
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
|
||||||
CheckoutCommit: "Checkout commit",
|
CheckoutCommit: "Checkout commit",
|
||||||
|
@ -229,5 +229,6 @@ func polishTranslationSet() TranslationSet {
|
|||||||
LcCopiedToClipboard: "skopiowany do schowka",
|
LcCopiedToClipboard: "skopiowany do schowka",
|
||||||
CreatePullRequestOptions: "Utwórz opcje żądania ściągnięcia",
|
CreatePullRequestOptions: "Utwórz opcje żądania ściągnięcia",
|
||||||
LcCreatePullRequestOptions: "utwórz opcje żądania ściągnięcia",
|
LcCreatePullRequestOptions: "utwórz opcje żądania ściągnięcia",
|
||||||
|
ConfirmRevertCommit: "Czy na pewno chcesz obrócić {{.selectedCommit}}?",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user