Skip to content
Open
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
7 changes: 5 additions & 2 deletions pkg/gui/presentation/remote_branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
)

func GetRemoteBranchListDisplayStrings(branches []*models.RemoteBranch, diffName string) [][]string {
return lo.Map(branches, func(branch *models.RemoteBranch, _ int) []string {
return lo.FilterMap(branches, func(branch *models.RemoteBranch, _ int) ([]string, bool) {
if branch == nil {
return nil, false
}
diffed := branch.FullName() == diffName
return getRemoteBranchDisplayStrings(branch, diffed)
return getRemoteBranchDisplayStrings(branch, diffed), true
})
}

Expand Down
18 changes: 18 additions & 0 deletions pkg/gui/presentation/remote_branches_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package presentation

import (
"testing"

"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/stretchr/testify/assert"
)

func TestGetRemoteBranchListDisplayStrings_NilBranch(t *testing.T) {
branch := &models.RemoteBranch{Name: "main", RemoteName: "origin"}
branches := []*models.RemoteBranch{nil, branch, nil}

result := GetRemoteBranchListDisplayStrings(branches, "")

// nil entries must be skipped; only the valid branch produces a row
assert.Len(t, result, 1)
}