1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

more refactoring

WIP

WIP
This commit is contained in:
Jesse Duffield
2021-06-05 15:56:50 +10:00
parent 93bf691fd6
commit 9fdf92b226
5 changed files with 81 additions and 38 deletions

View File

@ -33,13 +33,8 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
nameColorAttr = theme.DiffTerminalColor
}
coloredName := utils.ColoredString(displayName, nameColorAttr)
if b.Pushables != "" && b.Pullables != "" && b.Pushables != "?" && b.Pullables != "?" {
trackColor := color.FgYellow
if b.Pushables == "0" && b.Pullables == "0" {
trackColor = color.FgGreen
}
track := utils.ColoredString(fmt.Sprintf("↑%s↓%s", b.Pushables, b.Pullables), trackColor)
coloredName = fmt.Sprintf("%s %s", coloredName, track)
if b.IsTrackingRemote() {
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
}
recencyColor := color.FgCyan
@ -69,3 +64,18 @@ func GetBranchColor(name string) color.Attribute {
return theme.DefaultTextColor
}
}
func ColoredBranchStatus(branch *models.Branch) string {
colour := color.FgYellow
if branch.MatchesUpstream() {
colour = color.FgGreen
} else if !branch.IsTrackingRemote() {
colour = color.FgRed
}
return utils.ColoredString(BranchStatus(branch), colour)
}
func BranchStatus(branch *models.Branch) string {
return fmt.Sprintf("↑%s↓%s", branch.Pushables, branch.Pullables)
}