diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-04-18 10:44:45 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-04-18 11:03:28 +1000 |
commit | dfb293c9859980766bace8360ad26563d02e1345 (patch) | |
tree | 180522ebd37a25267d0f33c0a9267db8cd1dce5f /pkg/gui | |
parent | 9b947b74a2170a9a89a6f6e9bdf8772bd7e4ee85 (diff) |
better upstream changes presentation
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/presentation/branches.go | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go index b97ef6a5f..b7d8b0270 100644 --- a/pkg/gui/presentation/branches.go +++ b/pkg/gui/presentation/branches.go @@ -32,10 +32,10 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool if diffed { nameTextStyle = theme.DiffTerminalColor } + coloredName := nameTextStyle.Sprint(displayName) - if b.IsTrackingRemote() { - coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b, tr)) - } + branchStatus := utils.WithPadding(ColoredBranchStatus(b, tr), 2) + coloredName = fmt.Sprintf("%s %s", coloredName, branchStatus) recencyColor := style.FgCyan if b.Recency == " *" { @@ -77,20 +77,42 @@ func GetBranchTextStyle(name string) style.TextStyle { func ColoredBranchStatus(branch *models.Branch, tr *i18n.TranslationSet) string { colour := style.FgYellow - if !branch.IsTrackingRemote() || branch.UpstreamGone { + if branch.UpstreamGone { colour = style.FgRed } else if branch.MatchesUpstream() { colour = style.FgGreen + } else if branch.RemoteBranchNotStoredLocally() { + colour = style.FgMagenta } return colour.Sprint(BranchStatus(branch, tr)) } func BranchStatus(branch *models.Branch, tr *i18n.TranslationSet) string { + if !branch.IsTrackingRemote() { + return "" + } + if branch.UpstreamGone { return tr.UpstreamGone } - return fmt.Sprintf("↑%s↓%s", branch.Pushables, branch.Pullables) + + if branch.MatchesUpstream() { + return "✓" + } + if branch.RemoteBranchNotStoredLocally() { + return "?" + } + + result := "" + if branch.HasCommitsToPush() { + result = fmt.Sprintf("↑%s", branch.Pushables) + } + if branch.HasCommitsToPull() { + result = fmt.Sprintf("%s↓%s", result, branch.Pullables) + } + + return result } func SetCustomBranches(customBranchColors map[string]string) { |