1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-15 22:26:40 +02:00
lazygit/pkg/integration/tests/branch/select_commits_of_current_branch.go
Stefan Haller 80b5e21bd5 Add a command to select all commits of the current branch
This is useful for seeing the combined diff of all commits of a branch.
2025-04-10 09:02:09 +02:00

75 lines
1.8 KiB
Go

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"),
)
},
})