mhutchie / vscode-git-graph

View a Git Graph of your repository in Visual Studio Code, and easily perform Git actions from the graph.
https://marketplace.visualstudio.com/items?itemName=mhutchie.git-graph
Other
2k stars 264 forks source link

Add Support for Custom Branch Colors #809

Open grel0 opened 7 months ago

grel0 commented 7 months ago

Describe the feature that you'd like It would be nice to have a feature that allows for the customization of branch colors based on branch names or patterns. This feature would enhance the visual representation of different branches in the Git Graph, making it easier to distinguish between them at a glance.

Additional context (optional) Enhanced visual differentiation between branches. Improved navigation and identification of branches in the Git Graph. Customization options to suit individual preferences and project requirements.

geekley commented 7 months ago

Yes, please! I was about to request this too.

It's better to use regexes than something like globs because they are simple to implement and the most flexible. Here's an example of how I'd like to set it up (and a good default, IMO):

// Each key name is a JS regex. Values are hex RGB codes.
// It matches against only the part after the remote name, if present
// (so respective local and remote branches have the same color).
"git-graph.graph.branchColors": {
  "^(?:master|main|stable|prod(?:uction)?)(?:$|\\b)": "#d9008f", // blue
  "^(?:latest|edge|unstable|dev(?:el(?:op(?:ment)?)?)?)(?:$|\\b)": "#00d90a", // green
  "^feat(?:ure)?s?(?:$|\\b)": "#a300d9", // purple
  "^(?:bugs?|(?:bug-?)?fix(?:es)?)(?:$|\\b)": "#d98500", // orange
  "^releases?(?:$|\\b)": "#00d9cc", // cyan
  "^hot-?fix(?:es)?(?:$|\\b)": "#0085d9", // red
  "^(?:sup|back-?)?ports?(?:$|\\b)": "#ffcc00", // yellow
}
"git-graph.graph.tagColors": {
  "^[vV]?\\d+(?:\\.\\d+)*[-/\\w]*(?:$|\\b)": "#00d9cc", // cyan
}

These defaults I'm suggesting are based on the git-flow branching model, with some possible name variations/synonyms people are likely to use.

Of course, if you e.g. removed the line for feature, the fallback is that you'd still get different colors for every feature/* branch, like how it works now.