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

34 lines
895 B
Go
Raw Normal View History

2020-02-25 11:55:36 +02:00
package presentation
import (
2020-03-27 13:53:50 +02:00
"fmt"
"github.com/fatih/color"
2020-02-25 11:55:36 +02:00
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/theme"
2020-03-27 13:53:50 +02:00
"github.com/jesseduffield/lazygit/pkg/utils"
2020-02-25 11:55:36 +02:00
)
func GetRemoteListDisplayStrings(remotes []*commands.Remote, diffName string) [][]string {
2020-02-25 11:55:36 +02:00
lines := make([][]string, len(remotes))
for i := range remotes {
diffed := remotes[i].Name == diffName
lines[i] = getRemoteDisplayStrings(remotes[i], diffed)
2020-02-25 11:55:36 +02:00
}
return lines
}
// getRemoteDisplayStrings returns the display string of branch
func getRemoteDisplayStrings(r *commands.Remote, diffed bool) []string {
2020-03-27 13:53:50 +02:00
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)}
2020-02-25 11:55:36 +02:00
}