github.com/Ryooooooga/lazygit@v0.8.1/pkg/commands/branch.go (about) 1 package commands 2 3 import ( 4 "fmt" 5 "strings" 6 7 "github.com/fatih/color" 8 "github.com/jesseduffield/lazygit/pkg/utils" 9 ) 10 11 // Branch : A git branch 12 // duplicating this for now 13 type Branch struct { 14 Name string 15 Recency string 16 Pushables string 17 Pullables string 18 Selected bool 19 } 20 21 // GetDisplayStrings returns the dispaly string of branch 22 func (b *Branch) GetDisplayStrings(isFocused bool) []string { 23 displayName := utils.ColoredString(b.Name, b.GetColor()) 24 if isFocused && b.Selected && b.Pushables != "" && b.Pullables != "" { 25 displayName = fmt.Sprintf("%s ā%sā%s", displayName, b.Pushables, b.Pullables) 26 } 27 28 return []string{b.Recency, displayName} 29 } 30 31 // GetColor branch color 32 func (b *Branch) GetColor() color.Attribute { 33 switch b.getType() { 34 case "feature": 35 return color.FgGreen 36 case "bugfix": 37 return color.FgYellow 38 case "hotfix": 39 return color.FgRed 40 default: 41 return color.FgWhite 42 } 43 } 44 45 // expected to return feature/bugfix/hotfix or blank string 46 func (b *Branch) getType() string { 47 return strings.Split(b.Name, "/")[0] 48 }