jesseduffield / jesseduffield/lazygit

`branchColorPatterns`: allow overlapping regexes by making evaluation order consistent

Open
#5,800 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
82.4k
Forks
3k
Avg merge
2d 18h
Merged PRs (30d)
19

Description

### Description

I tried to setup a detailed branch coloring for my projects, which led me to trying overlapping regexes.

But when a branch name matches **more than one** pattern, which pattern "wins" is non-deterministic, the same branch shows different colors across renders/restarts.

Example config:
```yaml
gui:
branchColorPatterns:
'^task/JT-\d+.*': 'green' # task branches of my team
'^task/.*': 'blue' # other task branches
```

Branch `task/XY-456-other` matches only the second -> consistently blue.

Branch `task/JT-123-example` matches **both** patterns -> I'd expect the first-listed one (green) to win
(or the last - which I also tried - but I would expect for it to be consistent).
Actual behavior is seemingly random: sometimes green, sometimes blue, it flips across renders/restarts.

|||
|---|---|
|Image|Image|

### Describe the solution you'd like

Having a well-defined precedence would be really nice for some fine-tuned branch-coloring scenarios, as shown in the example above.

### Describe alternatives you've considered

Since Go's regex engine doesn't support negative lookahead, overlapping patterns can't easily be made mutually exclusive as a workaround.

Contributor guide

Open the contributing guide

Research direction

No file or test is named in the issue. Start by locating the branchColorPatterns configuration and the branch-color matching path; add a regression case for overlapping patterns and verify that the selected color remains consistent across renders and restarts.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.