summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation/remotes.go
blob: 6c094ecfd8e951531be097dda4dc26de49876606 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package presentation

import (
	"github.com/jesseduffield/lazygit/pkg/commands/models"
	"github.com/jesseduffield/lazygit/pkg/gui/style"
	"github.com/jesseduffield/lazygit/pkg/theme"
)

func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]string {
	lines := make([][]string, len(remotes))

	for i := range remotes {
		diffed := remotes[i].Name == diffName
		lines[i] = getRemoteDisplayStrings(remotes[i], diffed)
	}

	return lines
}

// getRemoteDisplayStrings returns the display string of branch
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
	branchCount := len(r.Branches)

	nameColorAttr := theme.DefaultTextColor
	if diffed {
		nameColorAttr = theme.DiffTerminalColor
	}

	return []string{nameColorAttr.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount)}
}