Skip to content

Commit 952535e

Browse files
committed
Add ability to configure branch color patterns
1 parent ec410b2 commit 952535e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

docs/Config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ You can customize the color of branches based on the branch prefix:
814814
gui:
815815
branchColors:
816816
'docs': '#11aaff' # use a light blue for branches beginning with 'docs/'
817+
'ISSUE-*': '#ff5733' # use a bright orange for branches beginning with 'ISSUE-'
817818
```
818819

819820
## Example Coloring

pkg/gui/presentation/branches.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ func getBranchDisplayStrings(
123123
return res
124124
}
125125

126+
func matchColorPrefix(name string) (style.TextStyle, bool) {
127+
for possiblePattern, color := range branchPrefixColorCache {
128+
if strings.Contains(possiblePattern, "*") {
129+
prefix := strings.TrimSuffix(possiblePattern, "*")
130+
if strings.HasPrefix(name, prefix) {
131+
return color, true
132+
}
133+
}
134+
}
135+
136+
return style.TextStyle{}, false
137+
}
138+
126139
// GetBranchTextStyle branch color
127140
func GetBranchTextStyle(name string) style.TextStyle {
128141
branchType := strings.Split(name, "/")[0]
@@ -131,6 +144,10 @@ func GetBranchTextStyle(name string) style.TextStyle {
131144
return value
132145
}
133146

147+
if value, ok := matchColorPrefix(name); ok {
148+
return value
149+
}
150+
134151
switch branchType {
135152
case "feature":
136153
return style.FgGreen

0 commit comments

Comments
 (0)