From 655f913f4428418e087fd1808de89c1ddc9af60c Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 29 Aug 2026 16:58:16 +0200 Subject: [PATCH 1/3] Add test for filtering worktrees --- .../filter_and_search/filter_worktrees.go | 34 +++++++++++++++++++ pkg/integration/tests/test_list.go | 1 + 2 files changed, 35 insertions(+) create mode 100644 pkg/integration/tests/filter_and_search/filter_worktrees.go diff --git a/pkg/integration/tests/filter_and_search/filter_worktrees.go b/pkg/integration/tests/filter_and_search/filter_worktrees.go new file mode 100644 index 00000000000..84e3675730e --- /dev/null +++ b/pkg/integration/tests/filter_and_search/filter_worktrees.go @@ -0,0 +1,34 @@ +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-xxx branch-aaa"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 0124de2684e..bf4cfd5df52 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -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, From c3027caf6be9432c3500996b1b47a11d0e78eec4 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 18 Aug 2026 09:21:37 +0200 Subject: [PATCH 2/3] Cleanup: use lowercase for function parameters --- pkg/gui/context/worktrees_context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/gui/context/worktrees_context.go b/pkg/gui/context/worktrees_context.go index 3e45f2d4581..4ff536c9433 100644 --- a/pkg/gui/context/worktrees_context.go +++ b/pkg/gui/context/worktrees_context.go @@ -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} }, ) From 530d773052cdeb3a0c9060f3e6cc5ecde035dd67 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Tue, 18 Aug 2026 09:23:30 +0200 Subject: [PATCH 3/3] Allow filtering worktrees by branch name in Worktrees pane Co-authored-by: phanirithvij --- pkg/gui/context/worktrees_context.go | 2 +- pkg/integration/tests/filter_and_search/filter_worktrees.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/gui/context/worktrees_context.go b/pkg/gui/context/worktrees_context.go index 4ff536c9433..690fa6d4be1 100644 --- a/pkg/gui/context/worktrees_context.go +++ b/pkg/gui/context/worktrees_context.go @@ -17,7 +17,7 @@ func NewWorktreesContext(c *ContextCommon) *WorktreesContext { viewModel := NewFilteredListViewModel( func() []*models.Worktree { return c.Model().Worktrees }, func(worktree *models.Worktree) []string { - return []string{worktree.Name} + return []string{worktree.Name, worktree.Branch} }, ) diff --git a/pkg/integration/tests/filter_and_search/filter_worktrees.go b/pkg/integration/tests/filter_and_search/filter_worktrees.go index 84e3675730e..77dbcc744d6 100644 --- a/pkg/integration/tests/filter_and_search/filter_worktrees.go +++ b/pkg/integration/tests/filter_and_search/filter_worktrees.go @@ -28,6 +28,7 @@ var FilterWorktrees = NewIntegrationTest(NewIntegrationTestArgs{ ). FilterOrSearch("xxx"). Lines( + Contains("worktree-1 branch-xxx"), Contains("worktree-xxx branch-aaa"), ) },