1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-17 00:18:05 +02:00

split RemoteBranch out from Branch

This commit is contained in:
Jesse Duffield
2019-11-17 10:23:06 +11:00
parent b7f2d0366b
commit 1f3e1720a3
8 changed files with 46 additions and 17 deletions

View File

@ -22,7 +22,7 @@ type Branch struct {
// GetDisplayStrings returns the display string of branch
func (b *Branch) GetDisplayStrings(isFocused bool) []string {
displayName := utils.ColoredString(b.Name, b.GetColor())
displayName := utils.ColoredString(b.Name, GetBranchColor(b.Name))
if isFocused && b.Selected && b.Pushables != "" && b.Pullables != "" {
displayName = fmt.Sprintf("%s ↑%s↓%s", displayName, b.Pushables, b.Pullables)
}
@ -30,9 +30,11 @@ func (b *Branch) GetDisplayStrings(isFocused bool) []string {
return []string{b.Recency, displayName}
}
// GetColor branch color
func (b *Branch) GetColor() color.Attribute {
switch b.getType() {
// GetBranchColor branch color
func GetBranchColor(name string) color.Attribute {
branchType := strings.Split(name, "/")[0]
switch branchType {
case "feature":
return color.FgGreen
case "bugfix":
@ -43,8 +45,3 @@ func (b *Branch) GetColor() color.Attribute {
return theme.DefaultTextColor
}
}
// expected to return feature/bugfix/hotfix or blank string
func (b *Branch) getType() string {
return strings.Split(b.Name, "/")[0]
}