From c44231a7d71db0aac8efe5e1e40d40cf03a09116 Mon Sep 17 00:00:00 2001 From: Brandon Date: Wed, 8 Jan 2025 20:25:24 -0800 Subject: [PATCH] Add number of commits to cherry-pick confirmation prompt --- pkg/gui/controllers/helpers/cherry_pick_helper.go | 11 +++++++++-- pkg/i18n/english.go | 2 +- pkg/integration/tests/cherry_pick/cherry_pick.go | 4 ++-- .../tests/cherry_pick/cherry_pick_conflicts.go | 2 +- .../tests/cherry_pick/cherry_pick_during_rebase.go | 2 +- .../tests/cherry_pick/cherry_pick_range.go | 2 +- pkg/integration/tests/demo/cherry_pick.go | 2 +- pkg/integration/tests/reflog/cherry_pick.go | 2 +- 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index c21e7037a..47108df16 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -1,10 +1,13 @@ package helpers import ( + "strconv" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" ) @@ -67,8 +70,12 @@ func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context ty // Only to be called from the branch commits controller func (self *CherryPickHelper) Paste() error { self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.CherryPick, - Prompt: self.c.Tr.SureCherryPick, + Title: self.c.Tr.CherryPick, + Prompt: utils.ResolvePlaceholderString( + self.c.Tr.SureCherryPick, + map[string]string{ + "numCommits": strconv.Itoa(len(self.getData().CherryPickedCommits)), + }), HandleConfirm: func() error { isInRebase, err := self.c.Git().Status.IsInInteractiveRebase() if err != nil { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index e777bdc96..79e387142 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1337,7 +1337,7 @@ func EnglishTranslationSet() *TranslationSet { 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.", CherryPickCopyRangeTooltip: "Mark commits as copied from the last copied commit to the selected commit.", PasteCommits: "Paste (cherry-pick)", - SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?", + SureCherryPick: "Are you sure you want to cherry-pick the {{.numCommits}} copied commit(s) onto this branch?", CherryPick: "Cherry-pick", CannotCherryPickNonCommit: "Cannot cherry-pick this kind of todo item", CannotCherryPickMergeCommit: "Cherry-picking merge commits is not supported", diff --git a/pkg/integration/tests/cherry_pick/cherry_pick.go b/pkg/integration/tests/cherry_pick/cherry_pick.go index eefe73692..bfa02c5a3 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick.go @@ -66,7 +66,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")). Confirm() }). Tap(func() { @@ -95,7 +95,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")). Confirm() }). Tap(func() { diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go index b5b4e1fd9..cd968adf8 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_conflicts.go @@ -49,7 +49,7 @@ var CherryPickConflicts = NewIntegrationTest(NewIntegrationTestArgs{ t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")). Confirm() t.Common().AcknowledgeConflicts() diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go b/pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go index 6e2e2e6e4..e1fc115cf 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_during_rebase.go @@ -67,7 +67,7 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")). Confirm() }). Tap(func() { diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_range.go b/pkg/integration/tests/cherry_pick/cherry_pick_range.go index e68b9bd46..e41d64f4a 100644 --- a/pkg/integration/tests/cherry_pick/cherry_pick_range.go +++ b/pkg/integration/tests/cherry_pick/cherry_pick_range.go @@ -63,7 +63,7 @@ var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")). Confirm() }). Tap(func() { diff --git a/pkg/integration/tests/demo/cherry_pick.go b/pkg/integration/tests/demo/cherry_pick.go index de14100d3..a29f34bb9 100644 --- a/pkg/integration/tests/demo/cherry_pick.go +++ b/pkg/integration/tests/demo/cherry_pick.go @@ -71,7 +71,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ t.Wait(1000) t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 2 copied commit(s) onto this branch?")). Confirm() }). TopLines( diff --git a/pkg/integration/tests/reflog/cherry_pick.go b/pkg/integration/tests/reflog/cherry_pick.go index b8f8a9260..1416ef955 100644 --- a/pkg/integration/tests/reflog/cherry_pick.go +++ b/pkg/integration/tests/reflog/cherry_pick.go @@ -39,7 +39,7 @@ var CherryPick = NewIntegrationTest(NewIntegrationTestArgs{ Tap(func() { t.ExpectPopup().Alert(). Title(Equals("Cherry-pick")). - Content(Contains("Are you sure you want to cherry-pick the copied commits onto this branch?")). + Content(Contains("Are you sure you want to cherry-pick the 1 copied commit(s) onto this branch?")). Confirm() }). Lines(