summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-05-04 12:26:55 +0200
committerStefan Haller <stefan@haller-berlin.de>2024-05-04 15:54:02 +0200
commitd774996949ef1e93cc8c1c564996a4c9619f12d1 (patch)
treec3963ccfb0cd0f99ff0b2c60d92653aebdfb0d80
parent01abaf56deb5106f462b2d05002a11522dada57d (diff)
WIP Add showDivergenceFromBaseBranch configdivergence-from-base-branch-display
-rw-r--r--docs/Config.md1
-rw-r--r--pkg/config/user_config.go43
-rw-r--r--pkg/gui/presentation/branches.go33
-rw-r--r--schema/config.json10
4 files changed, 56 insertions, 31 deletions
diff --git a/docs/Config.md b/docs/Config.md
index d85637429..95220ba9c 100644
--- a/docs/Config.md
+++ b/docs/Config.md
@@ -74,6 +74,7 @@ gui:
showListFooter: true # for seeing the '5 of 20' message in list panels
showRandomTip: true
showBranchCommitHash: false # show commit hashes alongside branch names
+ showDivergenceFromBaseBranch: onlyBehind # one of 'off' | 'onlyBehind' | 'behindAndAhead'
showBottomLine: true # for hiding the bottom information line (unless it has important information to tell you)
showPanelJumps: true # for showing the jump-to-panel keybindings as panel subtitles
showCommandLog: true
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go
index c22594461..fc8cddffb 100644
--- a/pkg/config/user_config.go
+++ b/pkg/config/user_config.go
@@ -127,6 +127,8 @@ type GuiConfig struct {
CommitHashLength int `yaml:"commitHashLength" jsonschema:"minimum=0"`
// If true, show commit hashes alongside branch names in the branches view.
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
+ // Whether to show the divergence from the base branch in the branches view.
+ ShowDivergenceFromBaseBranch string `yaml:"showDivergenceFromBaseBranch" jsonschema:"enum=off,enum=onlyBehind,enum=behindAndAhead"`
// Height of the command log view
CommandLogSize int `yaml:"commandLogSize" jsonschema:"minimum=0"`
// Whether to split the main window when viewing file changes.
@@ -668,26 +670,27 @@ func GetDefaultConfig() *UserConfig {
UnstagedChangesColor: []string{"red"},
DefaultFgColor: []string{"default"},
},
- CommitLength: CommitLengthConfig{Show: true},
- SkipNoStagedFilesWarning: false,
- ShowListFooter: true,
- ShowCommandLog: true,
- ShowBottomLine: true,
- ShowPanelJumps: true,
- ShowFileTree: true,
- ShowRandomTip: true,
- ShowIcons: false,
- NerdFontsVersion: "",
- ShowFileIcons: true,
- CommitHashLength: 8,
- ShowBranchCommitHash: false,
- CommandLogSize: 8,
- SplitDiff: "auto",
- SkipRewordInEditorWarning: false,
- Border: "rounded",
- AnimateExplosion: true,
- PortraitMode: "auto",
- FilterMode: "substring",
+ CommitLength: CommitLengthConfig{Show: true},
+ SkipNoStagedFilesWarning: false,
+ ShowListFooter: true,
+ ShowCommandLog: true,
+ ShowBottomLine: true,
+ ShowPanelJumps: true,
+ ShowFileTree: true,
+ ShowRandomTip: true,
+ ShowIcons: false,
+ NerdFontsVersion: "",
+ ShowFileIcons: true,
+ CommitHashLength: 8,
+ ShowBranchCommitHash: false,
+ ShowDivergenceFromBaseBranch: "onlyBehind",
+ CommandLogSize: 8,
+ SplitDiff: "auto",
+ SkipRewordInEditorWarning: false,
+ Border: "rounded",
+ AnimateExplosion: true,
+ PortraitMode: "auto",
+ FilterMode: "substring",
Spinner: SpinnerConfig{
Frames: []string{"|", "/", "-", "\\"},
Rate: 50,
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index 0d7c07590..8829821df 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -172,18 +172,29 @@ func BranchStatus(
}
}
- ahead := branch.AheadOfBaseBranch.Load()
- behind := branch.BehindBaseBranch.Load()
- if ahead != 0 || behind != 0 {
- if result != "" {
- result += " "
- }
- if ahead != 0 && behind != 0 {
- result += style.FgCyan.Sprintf("↓%d↑%d", behind, ahead)
- } else if behind != 0 {
- result += style.FgCyan.Sprintf("↓%d", behind)
+ if userConfig.Gui.ShowDivergenceFromBaseBranch != "off" {
+ behind := branch.BehindBaseBranch.Load()
+ if userConfig.Gui.ShowDivergenceFromBaseBranch == "onlyBehind" {
+ if behind != 0 {
+ if result != "" {
+ result += " "
+ }
+ result += style.FgCyan.Sprintf("↓%d", behind)
+ }
} else {
- result += style.FgCyan.Sprintf("↑%d", ahead)
+ ahead := branch.AheadOfBaseBranch.Load()
+ if ahead != 0 || behind != 0 {
+ if result != "" {
+ result += " "
+ }
+ if ahead != 0 && behind != 0 {
+ result += style.FgCyan.Sprintf("↓%d↑%d", behind, ahead)
+ } else if behind != 0 {
+ result += style.FgCyan.Sprintf("↓%d", behind)
+ } else {
+ result += style.FgCyan.Sprintf("↑%d", ahead)
+ }
+ }
}
}
diff --git a/schema/config.json b/schema/config.json
index 05a2db151..1eb9d3aa4 100644
--- a/schema/config.json
+++ b/schema/config.json
@@ -319,6 +319,16 @@
"type": "boolean",
"description": "If true, show commit hashes alongside branch names in the branches view."
},
+ "showDivergenceFromBaseBranch": {
+ "type": "string",
+ "enum": [
+ "off",
+ "onlyBehind",
+ "behindAndAhead"
+ ],
+ "description": "Whether to show the divergence from the base branch in the branches view.",
+ "default": "onlyBehind"
+ },
"commandLogSize": {
"type": "integer",
"minimum": 0,