diff --git a/docs/Config.md b/docs/Config.md index e9a8dab2a..a569418e8 100644 --- a/docs/Config.md +++ b/docs/Config.md @@ -616,6 +616,7 @@ keybinding: openInBrowser: o viewBisectOptions: b startInteractiveRebase: i + selectCommitsOfCurrentBranch: '*' amendAttribute: resetAuthor: a setAuthor: A diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index c24bc736b..0c328580a 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -111,6 +111,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | Reset | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | Search the current view by text | | @@ -262,6 +263,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View commits | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | @@ -331,6 +333,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | Copy (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | Search the current view by text | | diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index 9d583a270..b78ffddb0 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -77,6 +77,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` C `` | コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | 検索を開始 | | @@ -125,6 +126,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | Reset | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | 検索を開始 | | @@ -363,6 +365,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | コミットをコピー (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | コミットを閲覧 | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | diff --git a/docs/keybindings/Keybindings_ko.md b/docs/keybindings/Keybindings_ko.md index 6ea53f3ce..8010f0854 100644 --- a/docs/keybindings/Keybindings_ko.md +++ b/docs/keybindings/Keybindings_ko.md @@ -64,6 +64,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` C `` | 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset cherry-picked (copied) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 커밋 보기 | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | @@ -94,6 +95,7 @@ _Legend: `` means ctrl+b, `` means alt+b, `B` means shift+b_ | `` C `` | 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset cherry-picked (copied) commits selection | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View selected item's files | | | `` w `` | View worktree options | | | `` / `` | 검색 시작 | | @@ -290,6 +292,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | View reset options | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | 커밋을 복사 (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View selected item's files | | | `` w `` | View worktree options | | | `` / `` | 검색 시작 | | diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index 1e3bd722d..369f1b4d9 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -177,6 +177,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | Bekijk reset opties | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Bekijk gecommite bestanden | | | `` w `` | View worktree options | | | `` / `` | Start met zoeken | | @@ -240,6 +241,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset cherry-picked (gekopieerde) commits selectie | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Bekijk commits | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | @@ -331,6 +333,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | Kopieer commit (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Reset cherry-picked (gekopieerde) commits selectie | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Bekijk gecommite bestanden | | | `` w `` | View worktree options | | | `` / `` | Start met zoeken | | diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index ab95bc0f9..7eb1db950 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -85,6 +85,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, | `` g `` | Reset | Wyświetl opcje resetu (miękki/mieszany/twardy) do wybranego elementu. | | `` C `` | Kopiuj (cherry-pick) | Oznacz commit jako skopiowany. Następnie, w widoku lokalnych commitów, możesz nacisnąć `V`, aby wkleić (cherry-pick) skopiowane commity do sprawdzonej gałęzi. W dowolnym momencie możesz nacisnąć ``, aby anulować zaznaczenie. | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Wyświetl pliki | | | `` w `` | Zobacz opcje drzewa pracy | | | `` / `` | Szukaj w bieżącym widoku po tekście | | @@ -272,6 +273,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, | `` C `` | Kopiuj (cherry-pick) | Oznacz commit jako skopiowany. Następnie, w widoku lokalnych commitów, możesz nacisnąć `V`, aby wkleić (cherry-pick) skopiowane commity do sprawdzonej gałęzi. W dowolnym momencie możesz nacisnąć ``, aby anulować zaznaczenie. | | `` `` | Resetuj wybrane (cherry-picked) commity | | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Pokaż commity | | | `` w `` | Zobacz opcje drzewa pracy | | | `` / `` | Filtruj bieżący widok po tekście | | @@ -312,6 +314,7 @@ Jeśli chcesz zamiast tego rozpocząć interaktywny rebase od wybranego commita, | `` C `` | Kopiuj (cherry-pick) | Oznacz commit jako skopiowany. Następnie, w widoku lokalnych commitów, możesz nacisnąć `V`, aby wkleić (cherry-pick) skopiowane commity do sprawdzonej gałęzi. W dowolnym momencie możesz nacisnąć ``, aby anulować zaznaczenie. | | `` `` | Resetuj wybrane (cherry-picked) commity | | | `` `` | Otwórz zewnętrzne narzędzie różnic (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Wyświetl pliki | | | `` w `` | Zobacz opcje drzewa pracy | | | `` / `` | Szukaj w bieżącym widoku po tekście | | diff --git a/docs/keybindings/Keybindings_pt.md b/docs/keybindings/Keybindings_pt.md index b09809519..49c92f6a6 100644 --- a/docs/keybindings/Keybindings_pt.md +++ b/docs/keybindings/Keybindings_pt.md @@ -183,6 +183,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | Reset | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | Copiar (cherry-pick) | Marcar commit como copiado. Então, dentro da visualização local de commits, você pode pressionar `V` para colar (cherry-pick) o(s) commit(s) copiado(s) em seu branch de check-out. A qualquer momento você pode pressionar `` para cancelar a seleção. | | `` `` | Abrir ferramenta de diff externa (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | Search the current view by text | | @@ -292,6 +293,7 @@ Veja a documentação: | `` C `` | Copiar (cherry-pick) | Marcar commit como copiado. Então, dentro da visualização local de commits, você pode pressionar `V` para colar (cherry-pick) o(s) commit(s) copiado(s) em seu branch de check-out. A qualquer momento você pode pressionar `` para cancelar a seleção. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Abrir ferramenta de diff externa (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View commits | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | @@ -343,6 +345,7 @@ Veja a documentação: | `` C `` | Copiar (cherry-pick) | Marcar commit como copiado. Então, dentro da visualização local de commits, você pode pressionar `V` para colar (cherry-pick) o(s) commit(s) copiado(s) em seu branch de check-out. A qualquer momento você pode pressionar `` para cancelar a seleção. | | `` `` | Reset copied (cherry-picked) commits selection | | | `` `` | Abrir ferramenta de diff externa (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | View files | | | `` w `` | View worktree options | | | `` / `` | Search the current view by text | | diff --git a/docs/keybindings/Keybindings_ru.md b/docs/keybindings/Keybindings_ru.md index eeb73c3cb..f8964c19d 100644 --- a/docs/keybindings/Keybindings_ru.md +++ b/docs/keybindings/Keybindings_ru.md @@ -134,6 +134,7 @@ _Связки клавиш_ | `` C `` | Скопировать отобранные коммит (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Сбросить отобранную (скопированную | cherry-picked) выборку коммитов | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Просмотреть коммиты | | | `` w `` | View worktree options | | | `` / `` | Filter the current view by text | | @@ -172,6 +173,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | Просмотреть параметры сброса | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | Скопировать отобранные коммит (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Просмотреть файлы выбранного элемента | | | `` w `` | View worktree options | | | `` / `` | Найти | | @@ -231,6 +233,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | Скопировать отобранные коммит (cherry-pick) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | Сбросить отобранную (скопированную | cherry-picked) выборку коммитов | | | `` `` | Open external diff tool (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | Просмотреть файлы выбранного элемента | | | `` w `` | View worktree options | | | `` / `` | Найти | | diff --git a/docs/keybindings/Keybindings_zh-CN.md b/docs/keybindings/Keybindings_zh-CN.md index de1cbb659..f90b9239e 100644 --- a/docs/keybindings/Keybindings_zh-CN.md +++ b/docs/keybindings/Keybindings_zh-CN.md @@ -64,6 +64,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` C `` | 复制提交(拣选) | 标记提交为已复制。然后,在本地提交视图中,你可以按 `V` (Cherry-Pick) 将已复制的提交粘贴到已检出的分支中。任何时候都可以按 `` 来取消选择。 | | `` `` | 重置已拣选(复制)的提交 | | | `` `` | 使用外部差异比较工具(git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 查看提交 | | | `` w `` | 查看工作区选项 | | | `` / `` | 通过文本过滤当前视图 | | @@ -108,6 +109,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` C `` | 复制提交(拣选) | 标记提交为已复制。然后,在本地提交视图中,你可以按 `V` (Cherry-Pick) 将已复制的提交粘贴到已检出的分支中。任何时候都可以按 `` 来取消选择。 | | `` `` | 重置已拣选(复制)的提交 | | | `` `` | 使用外部差异比较工具(git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 查看提交的文件 | | | `` w `` | 查看工作区选项 | | | `` / `` | 开始搜索 | | @@ -170,6 +172,7 @@ _图例:`` 意味着ctrl+b, `意味着Alt+b, `B` 意味着shift+b_ | `` g `` | 查看重置选项 | 查看重置选项 (soft/mixed/hard) 用于重置到选择项 | | `` C `` | 复制提交(拣选) | 标记提交为已复制。然后,在本地提交视图中,你可以按 `V` (Cherry-Pick) 将已复制的提交粘贴到已检出的分支中。任何时候都可以按 `` 来取消选择。 | | `` `` | 使用外部差异比较工具(git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 查看提交的文件 | | | `` w `` | 查看工作区选项 | | | `` / `` | 开始搜索 | | diff --git a/docs/keybindings/Keybindings_zh-TW.md b/docs/keybindings/Keybindings_zh-TW.md index f6abf403a..cdbaee64b 100644 --- a/docs/keybindings/Keybindings_zh-TW.md +++ b/docs/keybindings/Keybindings_zh-TW.md @@ -132,6 +132,7 @@ _說明:`` 表示 Ctrl+B、`` 表示 Alt+B,`B`表示 Shift+B | `` C `` | 複製提交 (揀選) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | 重設選定的揀選 (複製) 提交 | | | `` `` | 開啟外部差異工具 (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 檢視所選項目的檔案 | | | `` w `` | 檢視工作目錄選項 | | | `` / `` | 搜尋 | | @@ -194,6 +195,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` g `` | 檢視重設選項 | View reset options (soft/mixed/hard) for resetting onto selected item. | | `` C `` | 複製提交 (揀選) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | 開啟外部差異工具 (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 檢視所選項目的檔案 | | | `` w `` | 檢視工作目錄選項 | | | `` / `` | 搜尋 | | @@ -250,6 +252,7 @@ If you would instead like to start an interactive rebase from the selected commi | `` C `` | 複製提交 (揀選) | Mark commit as copied. Then, within the local commits view, you can press `V` to paste (cherry-pick) the copied commit(s) into your checked out branch. At any time you can press `` to cancel the selection. | | `` `` | 重設選定的揀選 (複製) 提交 | | | `` `` | 開啟外部差異工具 (git difftool) | | +| `` * `` | Select commits of current branch | | | `` `` | 檢視提交 | | | `` w `` | 檢視工作目錄選項 | | | `` / `` | 搜尋 | | diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index fd682a9cb..165de3e34 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -516,6 +516,7 @@ type KeybindingCommitsConfig struct { OpenInBrowser string `yaml:"openInBrowser"` ViewBisectOptions string `yaml:"viewBisectOptions"` StartInteractiveRebase string `yaml:"startInteractiveRebase"` + SelectCommitsOfCurrentBranch string `yaml:"selectCommitsOfCurrentBranch"` } type KeybindingAmendAttributeConfig struct { @@ -991,6 +992,7 @@ func GetDefaultConfig() *UserConfig { OpenInBrowser: "o", ViewBisectOptions: "b", StartInteractiveRebase: "i", + SelectCommitsOfCurrentBranch: "*", }, AmendAttribute: KeybindingAmendAttributeConfig{ ResetAuthor: "a", diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index c98f8bab2..925f9e9d5 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -7,9 +7,11 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/git_commands" "github.com/jesseduffield/lazygit/pkg/commands/models" + "github.com/jesseduffield/lazygit/pkg/gui/context/traits" "github.com/jesseduffield/lazygit/pkg/gui/keybindings" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/samber/lo" ) // This controller is for all contexts that contain a list of commits. @@ -23,6 +25,8 @@ type ContainsCommits interface { GetSelectedItems() ([]*models.Commit, int, int) GetCommits() []*models.Commit GetSelectedLineIdx() int + GetSelectionRangeAndMode() (int, int, traits.RangeSelectMode) + SetSelectionRangeAndMode(int, int, traits.RangeSelectMode) } type BasicCommitsController struct { @@ -109,6 +113,12 @@ func (self *BasicCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ GetDisabledReason: self.require(self.singleItemSelected()), Description: self.c.Tr.OpenDiffTool, }, + { + Key: opts.GetKey(opts.Config.Commits.SelectCommitsOfCurrentBranch), + Handler: self.selectCommitsOfCurrentBranch, + GetDisabledReason: self.require(self.canSelectCommitsOfCurrentBranch), + Description: self.c.Tr.SelectCommitsOfCurrentBranch, + }, // Putting this at the bottom of the list so that it has the lowest priority, // meaning that if the user has configured another keybinding to the same key // then that will take precedence. @@ -389,3 +399,41 @@ func (self *BasicCommitsController) openDiffTool(commit *models.Commit) error { })) return err } + +func (self *BasicCommitsController) canSelectCommitsOfCurrentBranch() *types.DisabledReason { + if index := self.findFirstCommitAfterCurrentBranch(); index <= 0 { + return &types.DisabledReason{Text: self.c.Tr.NoCommitsThisBranch} + } + + return nil +} + +func (self *BasicCommitsController) findFirstCommitAfterCurrentBranch() int { + _, index, ok := lo.FindIndexOf(self.context.GetCommits(), func(c *models.Commit) bool { + return c.IsMerge() || c.Status == models.StatusMerged + }) + + if !ok { + return 0 + } + + return index +} + +func (self *BasicCommitsController) selectCommitsOfCurrentBranch() error { + index := self.findFirstCommitAfterCurrentBranch() + if index <= 0 { + return nil + } + + _, _, mode := self.context.GetSelectionRangeAndMode() + if mode != traits.RangeSelectModeSticky { + // If we are in sticky range mode already, keep that; otherwise, open a non-sticky range + mode = traits.RangeSelectModeNonSticky + } + // Create the range from bottom to top, so that when you cancel the range, + // the head commit is selected + self.context.SetSelectionRangeAndMode(0, index-1, mode) + self.context.HandleFocus(types.OnFocusOpts{}) + return nil +} diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index e91149b72..b2deb7ab1 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -861,6 +861,7 @@ type TranslationSet struct { CommandDoesNotSupportOpeningInEditor string CustomCommands string NoApplicableCommandsInThisContext string + SelectCommitsOfCurrentBranch string Actions Actions Bisect Bisect Log Log @@ -1918,6 +1919,7 @@ func EnglishTranslationSet() *TranslationSet { CommandDoesNotSupportOpeningInEditor: "This command doesn't support switching to the editor", CustomCommands: "Custom commands", NoApplicableCommandsInThisContext: "(No applicable commands in this context)", + SelectCommitsOfCurrentBranch: "Select commits of current branch", Actions: Actions{ // TODO: combine this with the original keybinding descriptions (those are all in lowercase atm) diff --git a/pkg/integration/tests/branch/select_commits_of_current_branch.go b/pkg/integration/tests/branch/select_commits_of_current_branch.go new file mode 100644 index 000000000..7b57455c3 --- /dev/null +++ b/pkg/integration/tests/branch/select_commits_of_current_branch.go @@ -0,0 +1,74 @@ +package branch + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var SelectCommitsOfCurrentBranch = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Select all commits of the current branch", + ExtraCmdArgs: []string{}, + Skip: false, + SetupConfig: func(config *config.AppConfig) {}, + SetupRepo: func(shell *Shell) { + shell.EmptyCommit("master 01") + shell.EmptyCommit("master 02") + shell.NewBranch("branch1") + shell.CreateNCommits(2) + shell.NewBranchFrom("branch2", "master") + shell.CreateNCommits(3) + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + Focus(). + Lines( + Contains("commit 03").IsSelected(), + Contains("commit 02"), + Contains("commit 01"), + Contains("master 02"), + Contains("master 01"), + ). + Press(keys.Commits.SelectCommitsOfCurrentBranch). + Lines( + Contains("commit 03").IsSelected(), + Contains("commit 02").IsSelected(), + Contains("commit 01").IsSelected(), + Contains("master 02"), + Contains("master 01"), + ). + PressEscape(). + Lines( + Contains("commit 03").IsSelected(), + Contains("commit 02"), + Contains("commit 01"), + Contains("master 02"), + Contains("master 01"), + ) + + t.Views().Branches(). + Focus(). + Lines( + Contains("branch2").IsSelected(), + Contains("branch1"), + Contains("master"), + ). + SelectNextItem(). + PressEnter() + + t.Views().SubCommits(). + IsFocused(). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01"), + Contains("master 02"), + Contains("master 01"), + ). + Press(keys.Commits.SelectCommitsOfCurrentBranch). + Lines( + Contains("commit 02").IsSelected(), + Contains("commit 01").IsSelected(), + Contains("master 02"), + Contains("master 01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index d76292526..c79dcd2f8 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -69,6 +69,7 @@ var tests = []*components.IntegrationTest{ branch.Rename, branch.Reset, branch.ResetToUpstream, + branch.SelectCommitsOfCurrentBranch, branch.SetUpstream, branch.ShowDivergenceFromBaseBranch, branch.ShowDivergenceFromUpstream, diff --git a/schema/config.json b/schema/config.json index 7c642af96..1f207af1d 100644 --- a/schema/config.json +++ b/schema/config.json @@ -938,6 +938,10 @@ "startInteractiveRebase": { "type": "string", "default": "i" + }, + "selectCommitsOfCurrentBranch": { + "type": "string", + "default": "*" } }, "additionalProperties": false,