From 280b4d60f893a0e20897091ab02617c32180b45d Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 13 Jan 2024 17:40:28 +1100 Subject: [PATCH] Support select range for cherry pick This requires us to change the 'v' keybinding for paste to something else, now that 'v' is used globally for toggling range select. So I'm using 'shift+v' and I'm likewise changing 'c' to 'shift+c' for copying, so that they're consistent. We will need to clearly communicate this change in keybindings. --- README.md | 2 +- docs/Config.md | 5 +- docs/keybindings/Keybindings_en.md | 11 +-- docs/keybindings/Keybindings_ja.md | 11 +-- docs/keybindings/Keybindings_ko.md | 11 +-- docs/keybindings/Keybindings_nl.md | 11 +-- docs/keybindings/Keybindings_pl.md | 11 +-- docs/keybindings/Keybindings_ru.md | 11 +-- docs/keybindings/Keybindings_zh-CN.md | 11 +-- docs/keybindings/Keybindings_zh-TW.md | 11 +-- pkg/config/user_config.go | 6 +- .../controllers/basic_commits_controller.go | 14 +-- .../controllers/helpers/cherry_pick_helper.go | 30 ++++--- pkg/i18n/chinese.go | 1 - pkg/i18n/dutch.go | 1 - pkg/i18n/english.go | 2 - pkg/i18n/japanese.go | 5 +- pkg/i18n/korean.go | 1 - pkg/i18n/polish.go | 1 - pkg/i18n/russian.go | 1 - pkg/i18n/traditional_chinese.go | 1 - .../tests/cherry_pick/cherry_pick_range.go | 85 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + schema/config.json | 8 +- 24 files changed, 148 insertions(+), 104 deletions(-) create mode 100644 pkg/integration/tests/cherry_pick/cherry_pick_range.go diff --git a/README.md b/README.md index ac45872e5..8aaf64850 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ You can also perform any these actions as a once-off (e.g. pressing `s` on a com ### Cherry-pick -Press `c` on a commit to copy it and press `v` to paste (cherry-pick) it. +Press `shift+c` on a commit to copy it and press `shift+v` to paste (cherry-pick) it. ![cherry_pick](../assets/demo/cherry_pick-compressed.gif) diff --git a/docs/Config.md b/docs/Config.md index 966fce0f4..dde60382a 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -249,9 +249,8 @@ keybinding: amendToCommit: 'A' pickCommit: 'p' # pick commit (when mid-rebase) revertCommit: 't' - cherryPickCopy: 'c' - cherryPickCopyRange: 'C' - pasteCommits: 'v' + cherryPickCopy: 'C' + pasteCommits: 'V' tagCommit: 'T' checkoutCommit: '' resetCherryPick: '' diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index b96d22ec6..04db47490 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -88,7 +88,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: Squash all 'fixup!' commits above selected commit (autosquash) <c-j>: Move commit down one <c-k>: Move commit up one - v: Paste commits (cherry-pick) + V: Paste commits (cherry-pick) B: Mark commit as base commit for rebase A: Amend commit with staged changes a: Set/Reset commit author @@ -101,8 +101,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: View reset options - c: Copy commit (cherry-pick) - C: Copy commit range (cherry-pick) + C: Copy commit (cherry-pick) <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files /: Search the current view by text @@ -248,8 +247,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: View reset options - c: Copy commit (cherry-pick) - C: Copy commit range (cherry-pick) + C: Copy commit (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: View commits @@ -316,8 +314,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: View reset options - c: Copy commit (cherry-pick) - C: Copy commit range (cherry-pick) + C: Copy commit (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index 4365e3685..3f7f9fb01 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -70,8 +70,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: ブラウザでコミットを開く n: コミットにブランチを作成 g: View reset options - c: コミットをコピー (cherry-pick) - C: コミットを範囲コピー (cherry-pick) + C: コミットをコピー (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files @@ -107,7 +106,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: Squash all 'fixup!' commits above selected commit (autosquash) <c-j>: コミットを1つ下に移動 <c-k>: コミットを1つ上に移動 - v: コミットを貼り付け (cherry-pick) + V: コミットを貼り付け (cherry-pick) B: Mark commit as base commit for rebase A: ステージされた変更でamendコミット a: Set/Reset commit author @@ -120,8 +119,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: ブラウザでコミットを開く n: コミットにブランチを作成 g: View reset options - c: コミットをコピー (cherry-pick) - C: コミットを範囲コピー (cherry-pick) + C: コミットをコピー (cherry-pick) <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files /: 検索を開始 @@ -348,8 +346,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: ブラウザでコミットを開く n: コミットにブランチを作成 g: View reset options - c: コミットをコピー (cherry-pick) - C: コミットを範囲コピー (cherry-pick) + C: コミットをコピー (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: コミットを閲覧 diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index 7d60e1b07..df5024617 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -57,8 +57,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 브라우저에서 커밋 열기 n: 커밋에서 새 브랜치를 만듭니다. g: View reset options - c: 커밋을 복사 (cherry-pick) - C: 커밋을 범위로 복사 (cherry-pick) + C: 커밋을 복사 (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: 커밋 보기 @@ -88,8 +87,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 브라우저에서 커밋 열기 n: 커밋에서 새 브랜치를 만듭니다. g: View reset options - c: 커밋을 복사 (cherry-pick) - C: 커밋을 범위로 복사 (cherry-pick) + C: 커밋을 복사 (cherry-pick) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files @@ -270,7 +268,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: Squash all 'fixup!' commits above selected commit (autosquash) <c-j>: 커밋을 1개 아래로 이동 <c-k>: 커밋을 1개 위로 이동 - v: 커밋을 붙여넣기 (cherry-pick) + V: 커밋을 붙여넣기 (cherry-pick) B: Mark commit as base commit for rebase A: Amend commit with staged changes a: Set/Reset commit author @@ -283,8 +281,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 브라우저에서 커밋 열기 n: 커밋에서 새 브랜치를 만듭니다. g: View reset options - c: 커밋을 복사 (cherry-pick) - C: 커밋을 범위로 복사 (cherry-pick) + C: 커밋을 복사 (cherry-pick) <c-t>: Open external diff tool (git difftool) <enter>: View selected item's files /: 검색 시작 diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 1a1d432d5..1ffd1ddcc 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -151,7 +151,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: Squash bovenstaande commits <c-j>: Verplaats commit 1 naar beneden <c-k>: Verplaats commit 1 naar boven - v: Plak commits (cherry-pick) + V: Plak commits (cherry-pick) B: Mark commit as base commit for rebase A: Wijzig commit met staged veranderingen a: Set/Reset commit author @@ -164,8 +164,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Creëer nieuwe branch van commit g: Bekijk reset opties - c: Kopieer commit (cherry-pick) - C: Kopieer commit reeks (cherry-pick) + C: Kopieer commit (cherry-pick) <c-t>: Open external diff tool (git difftool) <enter>: Bekijk gecommite bestanden /: Start met zoeken @@ -227,8 +226,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Creëer nieuwe branch van commit g: Bekijk reset opties - c: Kopieer commit (cherry-pick) - C: Kopieer commit reeks (cherry-pick) + C: Kopieer commit (cherry-pick) <c-r>: Reset cherry-picked (gekopieerde) commits selectie <c-t>: Open external diff tool (git difftool) <enter>: Bekijk commits @@ -316,8 +314,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Creëer nieuwe branch van commit g: Bekijk reset opties - c: Kopieer commit (cherry-pick) - C: Kopieer commit reeks (cherry-pick) + C: Kopieer commit (cherry-pick) <c-r>: Reset cherry-picked (gekopieerde) commits selectie <c-t>: Open external diff tool (git difftool) <enter>: Bekijk gecommite bestanden diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 3290d6e38..8b1061824 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -72,7 +72,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: Spłaszcz wszystkie commity naprawcze powyżej zaznaczonych commitów (autosquash) <c-j>: Przenieś commit 1 w dół <c-k>: Przenieś commit 1 w górę - v: Wklej commity (przebieranie) + V: Wklej commity (przebieranie) B: Mark commit as base commit for rebase A: Popraw commit zmianami z poczekalni a: Set/Reset commit author @@ -85,8 +85,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: Wyświetl opcje resetu - c: Kopiuj commit (przebieranie) - C: Kopiuj zakres commitów (przebieranie) + C: Kopiuj commit (przebieranie) <c-t>: Open external diff tool (git difftool) <enter>: Przeglądaj pliki commita /: Search the current view by text @@ -225,8 +224,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: Wyświetl opcje resetu - c: Kopiuj commit (przebieranie) - C: Kopiuj zakres commitów (przebieranie) + C: Kopiuj commit (przebieranie) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: View commits @@ -309,8 +307,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: Open commit in browser n: Create new branch off of commit g: Wyświetl opcje resetu - c: Kopiuj commit (przebieranie) - C: Kopiuj zakres commitów (przebieranie) + C: Kopiuj commit (przebieranie) <c-r>: Reset cherry-picked (copied) commits selection <c-t>: Open external diff tool (git difftool) <enter>: Przeglądaj pliki commita diff --git a/docs/keybindings/Keybindings_ru.md b/docs/keybindings/Keybindings_ru.md index 76cec5c5f..b2904d335 100644 --- a/docs/keybindings/Keybindings_ru.md +++ b/docs/keybindings/Keybindings_ru.md @@ -127,8 +127,7 @@ _Связки клавиш_ o: Открыть коммит в браузере n: Создать новую ветку с этого коммита g: Просмотреть параметры сброса - c: Скопировать отобранные коммит (cherry-pick) - C: Скопировать несколько отобранных коммитов (cherry-pick) + C: Скопировать отобранные коммит (cherry-pick) <c-r>: Сбросить отобранную (скопированную | cherry-picked) выборку коммитов <c-t>: Open external diff tool (git difftool) <enter>: Просмотреть коммиты @@ -153,7 +152,7 @@ _Связки клавиш_ S: Объединить все 'fixup!' коммиты выше в выбранный коммит (автосохранение) <c-j>: Переместить коммит вниз на один <c-k>: Переместить коммит вверх на один - v: Вставить отобранные коммиты (cherry-pick) + V: Вставить отобранные коммиты (cherry-pick) B: Mark commit as base commit for rebase A: Править последний коммит с проиндексированными изменениями a: Установить/убрать автора коммита @@ -166,8 +165,7 @@ _Связки клавиш_ o: Открыть коммит в браузере n: Создать новую ветку с этого коммита g: Просмотреть параметры сброса - c: Скопировать отобранные коммит (cherry-pick) - C: Скопировать несколько отобранных коммитов (cherry-pick) + C: Скопировать отобранные коммит (cherry-pick) <c-t>: Open external diff tool (git difftool) <enter>: Просмотреть файлы выбранного элемента /: Найти @@ -224,8 +222,7 @@ _Связки клавиш_ o: Открыть коммит в браузере n: Создать новую ветку с этого коммита g: Просмотреть параметры сброса - c: Скопировать отобранные коммит (cherry-pick) - C: Скопировать несколько отобранных коммитов (cherry-pick) + C: Скопировать отобранные коммит (cherry-pick) <c-r>: Сбросить отобранную (скопированную | cherry-picked) выборку коммитов <c-t>: Open external diff tool (git difftool) <enter>: Просмотреть файлы выбранного элемента diff --git a/docs/keybindings/Keybindings_zh-CN.md b/docs/keybindings/Keybindings_zh-CN.md index 333cfada5..1496f8624 100644 --- a/docs/keybindings/Keybindings_zh-CN.md +++ b/docs/keybindings/Keybindings_zh-CN.md @@ -57,8 +57,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 在浏览器中打开提交 n: 从提交创建新分支 g: 查看重置选项 - c: 复制提交(拣选) - C: 复制提交范围(拣选) + C: 复制提交(拣选) <c-r>: 重置已拣选(复制)的提交 <c-t>: Open external diff tool (git difftool) <enter>: 查看提交 @@ -112,8 +111,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 在浏览器中打开提交 n: 从提交创建新分支 g: 查看重置选项 - c: 复制提交(拣选) - C: 复制提交范围(拣选) + C: 复制提交(拣选) <c-r>: 重置已拣选(复制)的提交 <c-t>: Open external diff tool (git difftool) <enter>: 查看提交的文件 @@ -153,7 +151,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ S: 压缩在所选提交之上的所有“fixup!”提交(自动压缩) <c-j>: 下移提交 <c-k>: 上移提交 - v: 粘贴提交(拣选) + V: 粘贴提交(拣选) B: Mark commit as base commit for rebase A: 用已暂存的更改来修补提交 a: Set/Reset commit author @@ -166,8 +164,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ o: 在浏览器中打开提交 n: 从提交创建新分支 g: 查看重置选项 - c: 复制提交(拣选) - C: 复制提交范围(拣选) + C: 复制提交(拣选) <c-t>: Open external diff tool (git difftool) <enter>: 查看提交的文件 /: 开始搜索 diff --git a/docs/keybindings/Keybindings_zh-TW.md b/docs/keybindings/Keybindings_zh-TW.md index 81a2c4248..6243eafd4 100644 --- a/docs/keybindings/Keybindings_zh-TW.md +++ b/docs/keybindings/Keybindings_zh-TW.md @@ -57,8 +57,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B_ o: 在瀏覽器中開啟提交 n: 從提交建立新分支 g: 檢視重設選項 - c: 複製提交 (揀選) - C: 複製提交範圍 (揀選) + C: 複製提交 (揀選) <c-r>: 重設選定的揀選 (複製) 提交 <c-t>: Open external diff tool (git difftool) <enter>: 檢視提交 @@ -153,8 +152,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B_ o: 在瀏覽器中開啟提交 n: 從提交建立新分支 g: 檢視重設選項 - c: 複製提交 (揀選) - C: 複製提交範圍 (揀選) + C: 複製提交 (揀選) <c-r>: 重設選定的揀選 (複製) 提交 <c-t>: Open external diff tool (git difftool) <enter>: 檢視所選項目的檔案 @@ -194,7 +192,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B_ S: 壓縮上方所有的“fixup!”提交 (自動壓縮) <c-j>: 向下移動提交 <c-k>: 向上移動提交 - v: 貼上提交 (揀選) + V: 貼上提交 (揀選) B: Mark commit as base commit for rebase A: 使用已預存的更改修正提交 a: 設置/重設提交作者 @@ -207,8 +205,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B_ o: 在瀏覽器中開啟提交 n: 從提交建立新分支 g: 檢視重設選項 - c: 複製提交 (揀選) - C: 複製提交範圍 (揀選) + C: 複製提交 (揀選) <c-t>: Open external diff tool (git difftool) <enter>: 檢視所選項目的檔案 /: 開始搜尋 diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index a966905d0..e9f739a1d 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -418,7 +418,6 @@ type KeybindingCommitsConfig struct { PickCommit string `yaml:"pickCommit"` RevertCommit string `yaml:"revertCommit"` CherryPickCopy string `yaml:"cherryPickCopy"` - CherryPickCopyRange string `yaml:"cherryPickCopyRange"` PasteCommits string `yaml:"pasteCommits"` MarkCommitAsBaseForRebase string `yaml:"markCommitAsBaseForRebase"` CreateTag string `yaml:"tagCommit"` @@ -812,9 +811,8 @@ func GetDefaultConfig() *UserConfig { ResetCommitAuthor: "a", PickCommit: "p", RevertCommit: "t", - CherryPickCopy: "c", - CherryPickCopyRange: "C", - PasteCommits: "v", + CherryPickCopy: "C", + PasteCommits: "V", MarkCommitAsBaseForRebase: "B", CreateTag: "T", CheckoutCommit: "", diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 551349466..2f120a0f4 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -14,6 +14,7 @@ var _ types.IController = &BasicCommitsController{} type ContainsCommits interface { types.Context + types.IListContext GetSelected() *models.Commit GetCommits() []*models.Commit GetSelectedLineIdx() int @@ -64,13 +65,8 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ }, { Key: opts.GetKey(opts.Config.Commits.CherryPickCopy), - Handler: self.checkSelected(self.copy), - Description: self.c.Tr.CherryPickCopy, - }, - { - Key: opts.GetKey(opts.Config.Commits.CherryPickCopyRange), Handler: self.checkSelected(self.copyRange), - Description: self.c.Tr.CherryPickCopyRange, + Description: self.c.Tr.CherryPickCopy, }, { Key: opts.GetKey(opts.Config.Commits.ResetCherryPick), @@ -271,12 +267,8 @@ func (self *BasicCommitsController) checkout(commit *models.Commit) error { }) } -func (self *BasicCommitsController) copy(commit *models.Commit) error { - return self.c.Helpers().CherryPick.Copy(commit, self.context.GetCommits(), self.context) -} - func (self *BasicCommitsController) copyRange(*models.Commit) error { - return self.c.Helpers().CherryPick.CopyRange(self.context.GetSelectedLineIdx(), self.context.GetCommits(), self.context) + return self.c.Helpers().CherryPick.CopyRange(self.context.GetCommits(), self.context) } func (self *BasicCommitsController) openDiffTool(commit *models.Commit) error { diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 4f455ca30..61a37220b 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -5,6 +5,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/samber/lo" ) type CherryPickHelper struct { @@ -45,25 +46,30 @@ func (self *CherryPickHelper) Copy(commit *models.Commit, commitsList []*models. return self.rerender() } -func (self *CherryPickHelper) CopyRange(selectedIndex int, commitsList []*models.Commit, context types.Context) error { +func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context types.IListContext) error { + startIdx, endIdx := context.GetList().GetSelectionRange() + if err := self.resetIfNecessary(context); err != nil { return err } commitSet := self.getData().SelectedShaSet() - // find the last commit that is copied that's above our position - // if there are none, startIndex = 0 - startIndex := 0 - for index, commit := range commitsList[0:selectedIndex] { - if commitSet.Includes(commit.Sha) { - startIndex = index - } - } + allCommitsCopied := lo.EveryBy(commitsList[startIdx:endIdx+1], func(commit *models.Commit) bool { + return commitSet.Includes(commit.Sha) + }) - for index := startIndex; index <= selectedIndex; index++ { - commit := commitsList[index] - self.getData().Add(commit, commitsList) + // if all selected commits are already copied, we'll uncopy them + if allCommitsCopied { + for index := startIdx; index <= endIdx; index++ { + commit := commitsList[index] + self.getData().Remove(commit, commitsList) + } + } else { + for index := startIdx; index <= endIdx; index++ { + commit := commitsList[index] + self.getData().Add(commit, commitsList) + } } return self.rerender() diff --git a/pkg/i18n/chinese.go b/pkg/i18n/chinese.go index 0482f4046..8386bce1e 100644 --- a/pkg/i18n/chinese.go +++ b/pkg/i18n/chinese.go @@ -198,7 +198,6 @@ func chineseTranslationSet() TranslationSet { YouAreHere: "您在这里", RewordNotSupported: "当前不支持交互式重新基准化时的重新措词提交", CherryPickCopy: "复制提交(拣选)", - CherryPickCopyRange: "复制提交范围(拣选)", PasteCommits: "粘贴提交(拣选)", SureCherryPick: "您确定要将选中的提交进行拣选到这个分支吗?", CherryPick: "拣选 (Cherry-Pick)", diff --git a/pkg/i18n/dutch.go b/pkg/i18n/dutch.go index 79207490b..1e2eaa689 100644 --- a/pkg/i18n/dutch.go +++ b/pkg/i18n/dutch.go @@ -163,7 +163,6 @@ func dutchTranslationSet() TranslationSet { YouAreHere: "JE BENT HIER", RewordNotSupported: "Herformatteren van commits in interactief rebasen is nog niet ondersteund", CherryPickCopy: "Kopieer commit (cherry-pick)", - CherryPickCopyRange: "Kopieer commit reeks (cherry-pick)", PasteCommits: "Plak commits (cherry-pick)", SureCherryPick: "Weet je zeker dat je de gekopieerde commits naar deze branch wil cherry-picken?", CherryPick: "Cherry-Pick", diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index ad859dc1d..e9d0c9a65 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -251,7 +251,6 @@ type TranslationSet struct { RewordNotSupported string ChangingThisActionIsNotAllowed string CherryPickCopy string - CherryPickCopyRange string PasteCommits string SureCherryPick string CherryPick string @@ -1090,7 +1089,6 @@ func EnglishTranslationSet() TranslationSet { RewordNotSupported: "Rewording commits while interactively rebasing is not currently supported", ChangingThisActionIsNotAllowed: "Changing this kind of rebase todo entry is not allowed", CherryPickCopy: "Copy commit (cherry-pick)", - CherryPickCopyRange: "Copy commit range (cherry-pick)", PasteCommits: "Paste commits (cherry-pick)", SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?", CherryPick: "Cherry-pick", diff --git a/pkg/i18n/japanese.go b/pkg/i18n/japanese.go index 660746384..3da17b097 100644 --- a/pkg/i18n/japanese.go +++ b/pkg/i18n/japanese.go @@ -201,9 +201,8 @@ func japaneseTranslationSet() TranslationSet { // NoRoom: "Not enough room", YouAreHere: "現在位置", // LcRewordNotSupported: "Rewording commits while interactively rebasing is not currently supported", - CherryPickCopy: "コミットをコピー (cherry-pick)", - CherryPickCopyRange: "コミットを範囲コピー (cherry-pick)", - PasteCommits: "コミットを貼り付け (cherry-pick)", + CherryPickCopy: "コミットをコピー (cherry-pick)", + PasteCommits: "コミットを貼り付け (cherry-pick)", // SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?", CherryPick: "Cherry-Pick", Donate: "支援", diff --git a/pkg/i18n/korean.go b/pkg/i18n/korean.go index ad23090e7..3c4d0ceab 100644 --- a/pkg/i18n/korean.go +++ b/pkg/i18n/korean.go @@ -199,7 +199,6 @@ func koreanTranslationSet() TranslationSet { YouAreHere: "현재 위치", RewordNotSupported: "Rewording commits while interactively rebasing is not currently supported", CherryPickCopy: "커밋을 복사 (cherry-pick)", - CherryPickCopyRange: "커밋을 범위로 복사 (cherry-pick)", PasteCommits: "커밋을 붙여넣기 (cherry-pick)", SureCherryPick: "정말로 복사한 커밋을 이 브랜치에 체리픽하시겠습니까?", CherryPick: "체리픽", diff --git a/pkg/i18n/polish.go b/pkg/i18n/polish.go index ecab04281..e1515a948 100644 --- a/pkg/i18n/polish.go +++ b/pkg/i18n/polish.go @@ -131,7 +131,6 @@ func polishTranslationSet() TranslationSet { YouAreHere: "JESTEŚ TU", RewordNotSupported: "Przeredagowanie commitów podczas interaktywnej zmiany bazy nie jest obecnie wspierane", CherryPickCopy: "Kopiuj commit (przebieranie)", - CherryPickCopyRange: "Kopiuj zakres commitów (przebieranie)", PasteCommits: "Wklej commity (przebieranie)", SureCherryPick: "Czy na pewno chcesz przebierać w skopiowanych commitach na tej gałęzi?", CherryPick: "Przebieranie", diff --git a/pkg/i18n/russian.go b/pkg/i18n/russian.go index 387e34974..1522a0f1c 100644 --- a/pkg/i18n/russian.go +++ b/pkg/i18n/russian.go @@ -243,7 +243,6 @@ func RussianTranslationSet() TranslationSet { RewordNotSupported: "Переформулировка коммитов при интерактивном перебазировании в настоящее время не поддерживается", ChangingThisActionIsNotAllowed: "Изменение этого типа записи todo перебазирования не допускается", CherryPickCopy: "Скопировать отобранные коммит (cherry-pick)", - CherryPickCopyRange: "Скопировать несколько отобранных коммитов (cherry-pick)", PasteCommits: "Вставить отобранные коммиты (cherry-pick)", SureCherryPick: "Вы уверены, что хотите выборочно применить (cherry-picked) отобранные коммиты в эту ветку?", CherryPick: "Выборочная отборка (Cherry-Pick)", diff --git a/pkg/i18n/traditional_chinese.go b/pkg/i18n/traditional_chinese.go index 12207edcf..b9519bfcd 100644 --- a/pkg/i18n/traditional_chinese.go +++ b/pkg/i18n/traditional_chinese.go @@ -274,7 +274,6 @@ func traditionalChineseTranslationSet() TranslationSet { RewordNotSupported: "在互動變基期間改寫提交目前不支持", ChangingThisActionIsNotAllowed: "不允許更改此類變基待辦事項", CherryPickCopy: "複製提交 (揀選)", - CherryPickCopyRange: "複製提交範圍 (揀選)", PasteCommits: "貼上提交 (揀選)", SureCherryPick: "你確定要將複製的提交揀選到此分支嗎?", CherryPick: "揀選 (Cherry-pick)", diff --git a/pkg/integration/tests/cherry_pick/cherry_pick_range.go b/pkg/integration/tests/cherry_pick/cherry_pick_range.go new file mode 100644 index 000000000..99b29618f --- /dev/null +++ b/pkg/integration/tests/cherry_pick/cherry_pick_range.go @@ -0,0 +1,85 @@ +package cherry_pick + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var CherryPickRange = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Cherry pick range of commits from the subcommits view, without conflicts", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell. + EmptyCommit("base"). + NewBranch("first-branch"). + NewBranch("second-branch"). + Checkout("first-branch"). + EmptyCommit("one"). + EmptyCommit("two"). + Checkout("second-branch"). + EmptyCommit("three"). + EmptyCommit("four"). + Checkout("first-branch") + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Branches(). + Focus(). + Lines( + Contains("first-branch"), + Contains("second-branch"), + Contains("master"), + ). + SelectNextItem(). + PressEnter() + + t.Views().SubCommits(). + IsFocused(). + Lines( + Contains("four").IsSelected(), + Contains("three"), + Contains("base"), + ). + // copy commits 'four' and 'three' + Press(keys.Universal.RangeSelectDown). + Lines( + Contains("four").IsSelected(), + Contains("three").IsSelected(), + Contains("base"), + ). + Press(keys.Commits.CherryPickCopy) + + t.Views().Information().Content(Contains("2 commits copied")) + + t.Views().Commits(). + Focus(). + Lines( + Contains("two").IsSelected(), + Contains("one"), + Contains("base"), + ). + Press(keys.Commits.PasteCommits). + 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?")). + Confirm() + }). + Lines( + Contains("four"), + Contains("three"), + Contains("two"), + Contains("one"), + Contains("base"), + ). + Tap(func() { + // we need to manually exit out of cherry pick mode + t.Views().Information().Content(Contains("2 commits copied")) + }). + PressEscape(). + Tap(func() { + t.Views().Information().Content(DoesNotContain("commits copied")) + }) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 5b8e21e4b..8541f9a5c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -61,6 +61,7 @@ var tests = []*components.IntegrationTest{ cherry_pick.CherryPick, cherry_pick.CherryPickConflicts, cherry_pick.CherryPickDuringRebase, + cherry_pick.CherryPickRange, commit.AddCoAuthor, commit.Amend, commit.Commit, diff --git a/schema/config.json b/schema/config.json index 6d322ef3d..d5131c0ff 100644 --- a/schema/config.json +++ b/schema/config.json @@ -1101,16 +1101,12 @@ "default": "t" }, "cherryPickCopy": { - "type": "string", - "default": "c" - }, - "cherryPickCopyRange": { "type": "string", "default": "C" }, "pasteCommits": { "type": "string", - "default": "v" + "default": "V" }, "markCommitAsBaseForRebase": { "type": "string", @@ -1515,4 +1511,4 @@ }, "additionalProperties": false, "type": "object" -} +} \ No newline at end of file