mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-10 20:05:50 +02:00
fixup! WIP Add showDivergenceFromBaseBranch config
This commit is contained in:
parent
4d2177725f
commit
b23ea3b190
3 changed files with 31 additions and 9 deletions
|
@ -128,7 +128,7 @@ type GuiConfig struct {
|
|||
// 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"`
|
||||
ShowDivergenceFromBaseBranch string `yaml:"showDivergenceFromBaseBranch" jsonschema:"enum=off,enum=onlyBehindArrow,enum=onlyBehindArrowAndNumber,enum=behindAndAheadArrows,enum=behindAndAheadArrowsAndNumbers"`
|
||||
// Height of the command log view
|
||||
CommandLogSize int `yaml:"commandLogSize" jsonschema:"minimum=0"`
|
||||
// Whether to split the main window when viewing file changes.
|
||||
|
@ -683,7 +683,7 @@ func GetDefaultConfig() *UserConfig {
|
|||
ShowFileIcons: true,
|
||||
CommitHashLength: 8,
|
||||
ShowBranchCommitHash: false,
|
||||
ShowDivergenceFromBaseBranch: "onlyBehind",
|
||||
ShowDivergenceFromBaseBranch: "onlyBehindArrowAndNumber",
|
||||
CommandLogSize: 8,
|
||||
SplitDiff: "auto",
|
||||
SkipRewordInEditorWarning: false,
|
||||
|
|
|
@ -173,13 +173,21 @@ func BranchStatus(
|
|||
}
|
||||
|
||||
if userConfig.Gui.ShowDivergenceFromBaseBranch != "off" {
|
||||
showNumbers := userConfig.Gui.ShowDivergenceFromBaseBranch == "onlyBehindArrowAndNumber" ||
|
||||
userConfig.Gui.ShowDivergenceFromBaseBranch == "behindAndAheadArrowsAndNumbers"
|
||||
|
||||
behind := branch.BehindBaseBranch.Load()
|
||||
if userConfig.Gui.ShowDivergenceFromBaseBranch == "onlyBehind" {
|
||||
if userConfig.Gui.ShowDivergenceFromBaseBranch == "onlyBehindArrow" ||
|
||||
userConfig.Gui.ShowDivergenceFromBaseBranch == "onlyBehindArrowAndNumber" {
|
||||
if behind != 0 {
|
||||
if result != "" {
|
||||
result += " "
|
||||
}
|
||||
result += style.FgCyan.Sprintf("↓%d", behind)
|
||||
if showNumbers {
|
||||
result += style.FgCyan.Sprintf("↓%d", behind)
|
||||
} else {
|
||||
result += style.FgCyan.Sprintf("↓")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ahead := branch.AheadOfBaseBranch.Load()
|
||||
|
@ -188,11 +196,23 @@ func BranchStatus(
|
|||
result += " "
|
||||
}
|
||||
if ahead != 0 && behind != 0 {
|
||||
result += style.FgCyan.Sprintf("↓%d↑%d", behind, ahead)
|
||||
if showNumbers {
|
||||
result += style.FgCyan.Sprintf("↓%d↑%d", behind, ahead)
|
||||
} else {
|
||||
result += style.FgCyan.Sprint("↕")
|
||||
}
|
||||
} else if behind != 0 {
|
||||
result += style.FgCyan.Sprintf("↓%d", behind)
|
||||
if showNumbers {
|
||||
result += style.FgCyan.Sprintf("↓%d", behind)
|
||||
} else {
|
||||
result += style.FgCyan.Sprint("↓")
|
||||
}
|
||||
} else {
|
||||
result += style.FgCyan.Sprintf("↑%d", ahead)
|
||||
if showNumbers {
|
||||
result += style.FgCyan.Sprintf("↑%d", ahead)
|
||||
} else {
|
||||
result += style.FgCyan.Sprint("↑")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,8 +323,10 @@
|
|||
"type": "string",
|
||||
"enum": [
|
||||
"off",
|
||||
"onlyBehind",
|
||||
"behindAndAhead"
|
||||
"onlyBehindArrow",
|
||||
"onlyBehindArrowAndNumber",
|
||||
"behindAndAheadArrows",
|
||||
"behindAndAheadArrowsAndNumbers"
|
||||
],
|
||||
"description": "Whether to show the divergence from the base branch in the branches view.",
|
||||
"default": "onlyBehind"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue