1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-12 11:15:00 +02:00
lazygit/pkg/gui/presentation/remotes.go
2022-04-23 12:25:42 +09:00

34 lines
1.0 KiB
Go

package presentation
import (
"github.com/jesseduffield/generics/slices"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
)
func GetRemoteListDisplayStrings(remotes []*models.Remote, diffName string) [][]string {
return slices.Map(remotes, func(remote *models.Remote) []string {
diffed := remote.Name == diffName
return getRemoteDisplayStrings(remote, diffed)
})
}
// getRemoteDisplayStrings returns the display string of branch
func getRemoteDisplayStrings(r *models.Remote, diffed bool) []string {
branchCount := len(r.Branches)
textStyle := theme.DefaultTextColor
if diffed {
textStyle = theme.DiffTerminalColor
}
res := make([]string, 0, 3)
if icons.IsIconEnabled() {
res = append(res, textStyle.Sprint(icons.IconForRemote(r)))
}
res = append(res, textStyle.Sprint(r.Name), style.FgBlue.Sprintf("%d branches", branchCount))
return res
}