summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation/remotes.go
blob: 15a45089123396869f9ad4585a87e4fdf2501ca6 (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
31
32
33
package presentation

import (
	"fmt"

	"github.com/fatih/color"
	"github.com/jesseduffield/lazygit/pkg/commands/models"
	"github.com/jesseduffield/lazygit/pkg/theme"
	"github.com/jesseduffield/lazygit/pkg/utils"
)

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{utils.ColoredString(r.Name, nameColorAttr), utils.ColoredString(fmt.Sprintf("%d branches", branchCount), color.FgBlue)}
}