mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-27 09:46:10 -04:00
Demonstrate that author colors don't follow a change of gui.authorColors
If gui.authorColors changes while lazygit is running, the authors that are already on screen keep their old colors, both in the author column and in the commit graph. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
771e75c8ab
commit
46761ad2e5
@@ -3,8 +3,11 @@ package authors
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xo/terminfo"
|
||||
)
|
||||
|
||||
func TestGetInitials(t *testing.T) {
|
||||
@@ -41,3 +44,23 @@ func TestAuthorWithLength(t *testing.T) {
|
||||
assert.Equal(t, s.expectedOutput, utils.Decolorise(AuthorWithLength(s.authorName, s.length)))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuthorColorsFollowTheConfig(t *testing.T) {
|
||||
oldColorLevel := color.ForceSetColorLevel(terminfo.ColorLevelMillions)
|
||||
defer color.ForceSetColorLevel(oldColorLevel)
|
||||
t.Cleanup(func() { SetCustomAuthors(nil) })
|
||||
|
||||
SetCustomAuthors(map[string]string{"Jane Doe": "red"})
|
||||
assert.Equal(t, style.FgRed.Sprint("JD"), ShortAuthor("Jane Doe"))
|
||||
assert.Equal(t, style.FgRed.Sprint("Jane Doe"), LongAuthor("Jane Doe", 8))
|
||||
|
||||
SetCustomAuthors(map[string]string{"Jane Doe": "blue"})
|
||||
/* EXPECTED:
|
||||
assert.Equal(t, style.FgBlue.Sprint("JD"), ShortAuthor("Jane Doe"))
|
||||
ACTUAL: */
|
||||
assert.Equal(t, style.FgRed.Sprint("JD"), ShortAuthor("Jane Doe"))
|
||||
/* EXPECTED:
|
||||
assert.Equal(t, style.FgBlue.Sprint("Jane Doe"), LongAuthor("Jane Doe", 8))
|
||||
ACTUAL: */
|
||||
assert.Equal(t, style.FgRed.Sprint("Jane Doe"), LongAuthor("Jane Doe", 8))
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
"github.com/stefanhaller/git-todo-parser/todo"
|
||||
@@ -620,3 +623,27 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGraphColorsFollowTheAuthorColors(t *testing.T) {
|
||||
oldColorLevel := color.ForceSetColorLevel(terminfo.ColorLevelMillions)
|
||||
defer color.ForceSetColorLevel(oldColorLevel)
|
||||
t.Cleanup(func() { authors.SetCustomAuthors(nil) })
|
||||
|
||||
hashPool := &utils.StringPool{}
|
||||
commits := []*models.Commit{
|
||||
models.NewCommit(hashPool, models.NewCommitOpts{Hash: "authorcolors1", AuthorName: "Jane Doe", Parents: []string{"authorcolors2"}}),
|
||||
models.NewCommit(hashPool, models.NewCommitOpts{Hash: "authorcolors2", AuthorName: "Jane Doe"}),
|
||||
}
|
||||
renderGraph := func() string {
|
||||
return strings.Join(graph.RenderAux(loadPipesets(commits), commits, nil), "\n")
|
||||
}
|
||||
|
||||
authors.SetCustomAuthors(map[string]string{"Jane Doe": "red"})
|
||||
assert.Contains(t, renderGraph(), style.FgRed.Sprint("○"))
|
||||
|
||||
authors.SetCustomAuthors(map[string]string{"Jane Doe": "blue"})
|
||||
/* EXPECTED:
|
||||
assert.Contains(t, renderGraph(), style.FgBlue.Sprint("○"))
|
||||
ACTUAL: */
|
||||
assert.Contains(t, renderGraph(), style.FgRed.Sprint("○"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user