Skip to content

Commit b2c46c3

Browse files
authored
Add number of commits to cherry-pick confirmation prompt (#4158)
- **PR Description** The other day, I was cherry-picking a selection of commits and was annoyed that the "Are you sure..." prompt did not include the actual number of commits I was about to cherry-pick. I failed to realize the number of copied commits is displayed at the bottom right until going to update the integration tests. I personally think it's still nice to display the number in the actual confirmation prompt but feel free to close this PR if the change is unwanted.
2 parents 3518ec9 + c44231a commit b2c46c3

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

pkg/gui/controllers/helpers/cherry_pick_helper.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package helpers
22

33
import (
4+
"strconv"
5+
46
"github.com/jesseduffield/gocui"
57
"github.com/jesseduffield/lazygit/pkg/commands/models"
68
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
79
"github.com/jesseduffield/lazygit/pkg/gui/types"
10+
"github.com/jesseduffield/lazygit/pkg/utils"
811
"github.com/samber/lo"
912
)
1013

@@ -67,8 +70,12 @@ func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context ty
6770
// Only to be called from the branch commits controller
6871
func (self *CherryPickHelper) Paste() error {
6972
self.c.Confirm(types.ConfirmOpts{
70-
Title: self.c.Tr.CherryPick,
71-
Prompt: self.c.Tr.SureCherryPick,
73+
Title: self.c.Tr.CherryPick,
74+
Prompt: utils.ResolvePlaceholderString(
75+
self.c.Tr.SureCherryPick,
76+
map[string]string{
77+
"numCommits": strconv.Itoa(len(self.getData().CherryPickedCommits)),
78+
}),
7279
HandleConfirm: func() error {
7380
isInRebase, err := self.c.Git().Status.IsInInteractiveRebase()
7481
if err != nil {

pkg/i18n/english.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ func EnglishTranslationSet() *TranslationSet {
13371337
CherryPickCopyTooltip: "Mark commit as copied. Then, within the local commits view, you can press `{{.paste}}` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `{{.escape}}` to cancel the selection.",
13381338
CherryPickCopyRangeTooltip: "Mark commits as copied from the last copied commit to the selected commit.",
13391339
PasteCommits: "Paste (cherry-pick)",
1340-
SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?",
1340+
SureCherryPick: "Are you sure you want to cherry-pick the {{.numCommits}} copied commit(s) onto this branch?",
13411341
CherryPick: "Cherry-pick",
13421342
CannotCherryPickNonCommit: "Cannot cherry-pick this kind of todo item",
13431343
CannotCherryPickMergeCommit: "Cherry-picking merge commits is not supported",

pkg/integration/tests/cherry_pick/cherry_pick.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
6666
Tap(func() {
6767
t.ExpectPopup().Alert().
6868
Title(Equals("Cherry-pick")).
69-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
69+
Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
7070
Confirm()
7171
}).
7272
Tap(func() {
@@ -95,7 +95,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
9595
Tap(func() {
9696
t.ExpectPopup().Alert().
9797
Title(Equals("Cherry-pick")).
98-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
98+
Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
9999
Confirm()
100100
}).
101101
Tap(func() {

pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{
4949

5050
t.ExpectPopup().Alert().
5151
Title(Equals("Cherry-pick")).
52-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
52+
Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
5353
Confirm()
5454

5555
t.Common().AcknowledgeConflicts()

pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
6767
Tap(func() {
6868
t.ExpectPopup().Alert().
6969
Title(Equals("Cherry-pick")).
70-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
70+
Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")).
7171
Confirm()
7272
}).
7373
Tap(func() {

pkg/integration/tests/cherry_pick/cherry_pick_range.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{
6363
Tap(func() {
6464
t.ExpectPopup().Alert().
6565
Title(Equals("Cherry-pick")).
66-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
66+
Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
6767
Confirm()
6868
}).
6969
Tap(func() {

pkg/integration/tests/demo/cherry_pick.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
7171
t.Wait(1000)
7272
t.ExpectPopup().Alert().
7373
Title(Equals("Cherry-pick")).
74-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
74+
Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")).
7575
Confirm()
7676
}).
7777
TopLines(

pkg/integration/tests/reflog/cherry_pick.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{
3939
Tap(func() {
4040
t.ExpectPopup().Alert().
4141
Title(Equals("Cherry-pick")).
42-
Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")).
42+
Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")).
4343
Confirm()
4444
}).
4545
Lines(

0 commit comments

Comments
 (0)