Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/gui/context/worktrees_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var _ types.IListContext = (*WorktreesContext)(nil)
func NewWorktreesContext(c *ContextCommon) *WorktreesContext {
viewModel := NewFilteredListViewModel(
func() []*models.Worktree { return c.Model().Worktrees },
func(Worktree *models.Worktree) []string {
return []string{Worktree.Name}
func(worktree *models.Worktree) []string {
return []string{worktree.Name, worktree.Branch}
},
)

Expand Down
35 changes: 35 additions & 0 deletions pkg/integration/tests/filter_and_search/filter_worktrees.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package filter_and_search

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)

var FilterWorktrees = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Filtering worktrees by branch name",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.EmptyCommit("initial commit")
shell.NewBranch("branch-aaa")
shell.NewBranch("branch-xxx")
shell.Checkout("master")
shell.AddWorktreeCheckout("branch-aaa", "../worktree-xxx")
shell.AddWorktreeCheckout("branch-xxx", "../worktree-1")
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Worktrees().
Focus().
Lines(
Contains("(main worktree)").IsSelected(),
Contains("worktree-1 branch-xxx"),
Contains("worktree-xxx branch-aaa"),
).
FilterOrSearch("xxx").
Lines(
Contains("worktree-1 branch-xxx"),
Contains("worktree-xxx branch-aaa"),
)
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ var tests = []*components.IntegrationTest{
filter_and_search.FilterRemotes,
filter_and_search.FilterSearchHistory,
filter_and_search.FilterUpdatesWhenModelChanges,
filter_and_search.FilterWorktrees,
filter_and_search.NestedFilter,
filter_and_search.NestedFilterTransient,
filter_and_search.NewSearch,
Expand Down
Loading