diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-02 20:05:23 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-05 07:58:21 +1100 |
commit | f6ec7babf55c4a43bc8048e8a84970a8de8250b9 (patch) | |
tree | ffbfe8d8085feac9c69d1c29a1e44eff8e8ddb3a /pkg/gui | |
parent | 802cfb1a0436568c72fc998249f10f8150b352a3 (diff) |
add some config
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/list_context_config.go | 19 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 16 |
2 files changed, 31 insertions, 4 deletions
diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go index e9e585b37..3e19eaf75 100644 --- a/pkg/gui/list_context_config.go +++ b/pkg/gui/list_context_config.go @@ -1,6 +1,8 @@ package gui import ( + "log" + "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/presentation" "github.com/jesseduffield/lazygit/pkg/gui/style" @@ -173,6 +175,7 @@ func (gui *Gui) branchCommitsListContext() IListContext { selectedCommitSha, startIdx, length, + gui.shouldShowGraph(), ) }, SelectedItem: func() (ListItem, bool) { @@ -183,6 +186,21 @@ func (gui *Gui) branchCommitsListContext() IListContext { } } +func (gui *Gui) shouldShowGraph() bool { + value := gui.Config.GetUserConfig().Git.Log.ShowGraph + switch value { + case "always": + return true + case "never": + return false + case "when-maximised": + return gui.State.ScreenMode != SCREEN_NORMAL + } + + log.Fatalf("Unknown value for git.log.showGraph: %s. Expected one of: 'always', 'never', 'when-maximised'", value) + return false +} + func (gui *Gui) reflogCommitsListContext() IListContext { parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji return &ListContext{ @@ -242,6 +260,7 @@ func (gui *Gui) subCommitsListContext() IListContext { selectedCommitSha, 0, len(gui.State.SubCommits), + gui.shouldShowGraph(), ) }, SelectedItem: func() (ListItem, bool) { diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 2a24437c9..c4a02df29 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -30,6 +30,7 @@ func GetCommitListDisplayStrings( selectedCommitSha string, startIdx int, length int, + showGraph bool, ) [][]string { mutex.Lock() defer mutex.Unlock() @@ -61,13 +62,20 @@ func GetCommitListDisplayStrings( end = len(commits) - 1 } - filteredPipeSets := pipeSets[startIdx : end+1] filteredCommits := commits[startIdx : end+1] - graphLines := graph.RenderAux(filteredPipeSets, filteredCommits, selectedCommitSha) - lines := make([][]string, 0, len(graphLines)) + var getGraphLine func(int) string + if showGraph { + filteredPipeSets := pipeSets[startIdx : end+1] + graphLines := graph.RenderAux(filteredPipeSets, filteredCommits, selectedCommitSha) + getGraphLine = func(idx int) string { return graphLines[idx] } + } else { + getGraphLine = func(idx int) string { return "" } + } + + lines := make([][]string, 0, len(filteredCommits)) for i, commit := range filteredCommits { - lines = append(lines, displayCommit(commit, cherryPickedCommitShaMap, diffName, parseEmoji, graphLines[i], fullDescription)) + lines = append(lines, displayCommit(commit, cherryPickedCommitShaMap, diffName, parseEmoji, getGraphLine(i), fullDescription)) } return lines } |