mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-10 11:10:18 +02:00
38 lines
723 B
Go
38 lines
723 B
Go
package git
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/fatih/color"
|
|
)
|
|
|
|
// Branch : A git branch
|
|
type Branch struct {
|
|
Name string
|
|
Recency string
|
|
}
|
|
|
|
// GetDisplayString returns the dispaly string of branch
|
|
// func (b *Branch) GetDisplayString() string {
|
|
// return gui.withPadding(b.Recency, 4) + gui.coloredString(b.Name, b.getColor())
|
|
// }
|
|
|
|
// GetColor branch color
|
|
func (b *Branch) GetColor() color.Attribute {
|
|
switch b.getType() {
|
|
case "feature":
|
|
return color.FgGreen
|
|
case "bugfix":
|
|
return color.FgYellow
|
|
case "hotfix":
|
|
return color.FgRed
|
|
default:
|
|
return color.FgWhite
|
|
}
|
|
}
|
|
|
|
// expected to return feature/bugfix/hotfix or blank string
|
|
func (b *Branch) getType() string {
|
|
return strings.Split(b.Name, "/")[0]
|
|
}
|