summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-26 17:36:14 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 11:38:52 +0200
commit38274796432eabd3727580ba7d1bcfba6bcbe99f (patch)
tree8cbf03e0daac97378faa2f4fe15dc249772795c4 /pkg
parentd41a195ee6202b5754ba0e996f67a18675b85302 (diff)
Show correct keybindings in force-push prompt
Diffstat (limited to 'pkg')
-rw-r--r--pkg/gui/controllers/sync_controller.go15
-rw-r--r--pkg/i18n/english.go2
-rw-r--r--pkg/integration/tests/sync/force_push.go2
-rw-r--r--pkg/integration/tests/sync/force_push_multiple_matching.go2
-rw-r--r--pkg/integration/tests/sync/force_push_multiple_upstream.go2
5 files changed, 17 insertions, 6 deletions
diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go
index 9fa2da09c..2ec22b2a4 100644
--- a/pkg/gui/controllers/sync_controller.go
+++ b/pkg/gui/controllers/sync_controller.go
@@ -8,6 +8,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
type SyncController struct {
@@ -186,7 +187,7 @@ func (self *SyncController) pushAux(opts pushOpts) error {
}
_ = self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.ForcePush,
- Prompt: self.c.Tr.ForcePushPrompt,
+ Prompt: self.forcePushPrompt(),
HandleConfirm: func() error {
newOpts := opts
newOpts.force = true
@@ -210,10 +211,20 @@ func (self *SyncController) requestToForcePush(opts pushOpts) error {
return self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.ForcePush,
- Prompt: self.c.Tr.ForcePushPrompt,
+ Prompt: self.forcePushPrompt(),
HandleConfirm: func() error {
opts.force = true
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,
+ },
+ )
+}
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 274c5328e..84f881c5d 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -876,7 +876,7 @@ func EnglishTranslationSet() TranslationSet {
OpenConfig: "Open config file",
EditConfig: "Edit config file",
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",
UpdatesRejectedAndForcePushDisabled: "Updates were rejected and you have disabled force pushing",
CheckForUpdate: "Check for update",
diff --git a/pkg/integration/tests/sync/force_push.go b/pkg/integration/tests/sync/force_push.go
index cf8ec60f1..89d8a8371 100644
--- a/pkg/integration/tests/sync/force_push.go
+++ b/pkg/integration/tests/sync/force_push.go
@@ -32,7 +32,7 @@ var ForcePush = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation().
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()
t.Views().Commits().
diff --git a/pkg/integration/tests/sync/force_push_multiple_matching.go b/pkg/integration/tests/sync/force_push_multiple_matching.go
index 4f9998bb1..37c43f264 100644
--- a/pkg/integration/tests/sync/force_push_multiple_matching.go
+++ b/pkg/integration/tests/sync/force_push_multiple_matching.go
@@ -34,7 +34,7 @@ var ForcePushMultipleMatching = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation().
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()
t.Views().Commits().
diff --git a/pkg/integration/tests/sync/force_push_multiple_upstream.go b/pkg/integration/tests/sync/force_push_multiple_upstream.go
index f94e33e22..1ea512720 100644
--- a/pkg/integration/tests/sync/force_push_multiple_upstream.go
+++ b/pkg/integration/tests/sync/force_push_multiple_upstream.go
@@ -33,7 +33,7 @@ var ForcePushMultipleUpstream = NewIntegrationTest(NewIntegrationTestArgs{
t.ExpectPopup().Confirmation().
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()
t.Views().Commits().