summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-04-18 10:44:45 +1000
committerJesse Duffield <jessedduffield@gmail.com>2022-04-18 11:03:28 +1000
commitdfb293c9859980766bace8360ad26563d02e1345 (patch)
tree180522ebd37a25267d0f33c0a9267db8cd1dce5f
parent9b947b74a2170a9a89a6f6e9bdf8772bd7e4ee85 (diff)
better upstream changes presentation
-rw-r--r--pkg/commands/models/branch.go4
-rw-r--r--pkg/gui/presentation/branches.go32
-rw-r--r--pkg/i18n/english.go2
3 files changed, 32 insertions, 6 deletions
diff --git a/pkg/commands/models/branch.go b/pkg/commands/models/branch.go
index b41e157f3..1bf7369d9 100644
--- a/pkg/commands/models/branch.go
+++ b/pkg/commands/models/branch.go
@@ -44,6 +44,10 @@ func (b *Branch) RemoteBranchStoredLocally() bool {
return b.IsTrackingRemote() && b.Pushables != "?" && b.Pullables != "?"
}
+func (b *Branch) RemoteBranchNotStoredLocally() bool {
+ return b.IsTrackingRemote() && b.Pushables == "?" && b.Pullables == "?"
+}
+
func (b *Branch) MatchesUpstream() bool {
return b.RemoteBranchStoredLocally() && b.Pushables == "0" && b.Pullables == "0"
}
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) {
diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go
index 585da5e30..a341447dc 100644
--- a/pkg/i18n/english.go
+++ b/pkg/i18n/english.go
@@ -1077,7 +1077,7 @@ func EnglishTranslationSet() TranslationSet {
RewordInEditorPrompt: "Are you sure you want to reword this commit in your editor?",
HardResetAutostashPrompt: "Are you sure you want to hard reset to '%s'? An auto-stash will be performed if necessary.",
CheckoutPrompt: "Are you sure you want to checkout '%s'?",
- UpstreamGone: "↑gone",
+ UpstreamGone: "(upstream gone)",
Actions: Actions{
// TODO: combine this with the original keybinding descriptions (those are all in lowercase atm)
CheckoutCommit: "Checkout commit",