1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-03 15:02:52 +02:00

Show correct keybindings in force-push prompt

This commit is contained in:
Stefan Haller 2023-07-26 17:36:14 +02:00
parent d41a195ee6
commit 3827479643
5 changed files with 17 additions and 6 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
) )
type SyncController struct { type SyncController struct {
@ -186,7 +187,7 @@ func (self *SyncController) pushAux(opts pushOpts) error {
} }
_ = self.c.Confirm(types.ConfirmOpts{ _ = self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.ForcePush, Title: self.c.Tr.ForcePush,
Prompt: self.c.Tr.ForcePushPrompt, Prompt: self.forcePushPrompt(),
HandleConfirm: func() error { HandleConfirm: func() error {
newOpts := opts newOpts := opts
newOpts.force = true newOpts.force = true
@ -210,10 +211,20 @@ func (self *SyncController) requestToForcePush(opts pushOpts) error {
return self.c.Confirm(types.ConfirmOpts{ return self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.ForcePush, Title: self.c.Tr.ForcePush,
Prompt: self.c.Tr.ForcePushPrompt, Prompt: self.forcePushPrompt(),
HandleConfirm: func() error { HandleConfirm: func() error {
opts.force = true opts.force = true
return self.pushAux(opts) return self.pushAux(opts)
}, },
}) })
} }
func (self *SyncController) forcePushPrompt() string {
return utils.ResolvePlaceholderString(
self.c.Tr.ForcePushPrompt,
map[string]string{
"cancelKey": self.c.UserConfig.Keybinding.Universal.Return,
"confirmKey": self.c.UserConfig.Keybinding.Universal.Confirm,
},
)
}

View File

@ -876,7 +876,7 @@ func EnglishTranslationSet() TranslationSet {
OpenConfig: "Open config file", OpenConfig: "Open config file",
EditConfig: "Edit config file", EditConfig: "Edit config file",
ForcePush: "Force push", ForcePush: "Force push",
ForcePushPrompt: "Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.", ForcePushPrompt: "Your branch has diverged from the remote branch. Press {{.cancelKey}} to cancel, or {{.confirmKey}} to force push.",
ForcePushDisabled: "Your branch has diverged from the remote branch and you've disabled force pushing", ForcePushDisabled: "Your branch has diverged from the remote branch and you've disabled force pushing",
UpdatesRejectedAndForcePushDisabled: "Updates were rejected and you have disabled force pushing", UpdatesRejectedAndForcePushDisabled: "Updates were rejected and you have disabled force pushing",
CheckForUpdate: "Check for update", CheckForUpdate: "Check for update",

View File

@ -32,7 +32,7 @@ var ForcePush = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation(). t.ExpectPopup().Confirmation().
Title(Equals("Force push")). Title(Equals("Force push")).
Content(Equals("Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.")). Content(Equals("Your branch has diverged from the remote branch. Press <esc> to cancel, or <enter> to force push.")).
Confirm() Confirm()
t.Views().Commits(). t.Views().Commits().

View File

@ -34,7 +34,7 @@ var ForcePushMultipleMatching = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation(). t.ExpectPopup().Confirmation().
Title(Equals("Force push")). Title(Equals("Force push")).
Content(Equals("Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.")). Content(Equals("Your branch has diverged from the remote branch. Press <esc> to cancel, or <enter> to force push.")).
Confirm() Confirm()
t.Views().Commits(). t.Views().Commits().

View File

@ -33,7 +33,7 @@ var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation(). t.ExpectPopup().Confirmation().
Title(Equals("Force push")). Title(Equals("Force push")).
Content(Equals("Your branch has diverged from the remote branch. Press 'esc' to cancel, or 'enter' to force push.")). Content(Equals("Your branch has diverged from the remote branch. Press <esc> to cancel, or <enter> to force push.")).
Confirm() Confirm()
t.Views().Commits(). t.Views().Commits().