diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-05 15:56:50 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-06-06 09:12:49 +1000 |
commit | 9fdf92b226032d39503dbf40ef931d5d017b4235 (patch) | |
tree | 469a401c8b7df10d2ccb7f2b6ba59607c2029042 /pkg/gui/presentation | |
parent | 93bf691fd66cfd19702db2a674c73fbefc244467 (diff) |
more refactoring
WIP
WIP
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r-- | pkg/gui/presentation/branches.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go index 72def1f6c..3e51e3d66 100644 --- a/pkg/gui/presentation/branches.go +++ b/pkg/gui/presentation/branches.go @@ -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) +} |