mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-15 00:15:32 +02:00
add some config
This commit is contained in:
@ -61,6 +61,14 @@ git:
|
|||||||
manualCommit: false
|
manualCommit: false
|
||||||
# extra args passed to `git merge`, e.g. --no-ff
|
# extra args passed to `git merge`, e.g. --no-ff
|
||||||
args: ''
|
args: ''
|
||||||
|
log:
|
||||||
|
# one of date-order, reverse, author-date-order, topo-order.
|
||||||
|
# topo-order makes it easier to read the git log graph, but commits may not
|
||||||
|
# appear chronologically. See https://git-scm.com/docs/git-log#_commit_ordering
|
||||||
|
order: 'topo-order'
|
||||||
|
# one of always, never, when-maximised
|
||||||
|
# this determines whether the git graph is rendered in the commits panel
|
||||||
|
showGraph: 'when-maximised'
|
||||||
skipHookPrefix: WIP
|
skipHookPrefix: WIP
|
||||||
autoFetch: true
|
autoFetch: true
|
||||||
branchLogCmd: 'git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --'
|
branchLogCmd: 'git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --'
|
||||||
@ -103,7 +111,7 @@ keybinding:
|
|||||||
nextBlock: '<right>' # goto the next block / panel
|
nextBlock: '<right>' # goto the next block / panel
|
||||||
prevBlock-alt: 'h' # goto the previous block / panel
|
prevBlock-alt: 'h' # goto the previous block / panel
|
||||||
nextBlock-alt: 'l' # goto the next block / panel
|
nextBlock-alt: 'l' # goto the next block / panel
|
||||||
jumpToBlock: ["1", "2", "3", "4", "5"] # goto the Nth block / panel
|
jumpToBlock: ['1', '2', '3', '4', '5'] # goto the Nth block / panel
|
||||||
nextMatch: 'n'
|
nextMatch: 'n'
|
||||||
prevMatch: 'N'
|
prevMatch: 'N'
|
||||||
optionMenu: 'x' # show help menu
|
optionMenu: 'x' # show help menu
|
||||||
|
@ -404,10 +404,15 @@ func (c *CommitListBuilder) getLogCmd(opts GetCommitsOptions) *exec.Cmd {
|
|||||||
filterFlag = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(opts.FilterPath))
|
filterFlag = fmt.Sprintf(" --follow -- %s", c.OSCommand.Quote(opts.FilterPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config := c.GitCommand.Config.GetUserConfig().Git.Log
|
||||||
|
|
||||||
|
orderFlag := "--" + config.Order
|
||||||
|
|
||||||
return c.OSCommand.ExecutableFromString(
|
return c.OSCommand.ExecutableFromString(
|
||||||
fmt.Sprintf(
|
fmt.Sprintf(
|
||||||
"git log --topo-order %s --oneline %s %s --abbrev=%d %s",
|
"git log %s %s --oneline %s %s --abbrev=%d %s",
|
||||||
c.OSCommand.Quote(opts.RefName),
|
c.OSCommand.Quote(opts.RefName),
|
||||||
|
orderFlag,
|
||||||
prettyFormat,
|
prettyFormat,
|
||||||
limitFlag,
|
limitFlag,
|
||||||
20,
|
20,
|
||||||
|
@ -69,7 +69,9 @@ type GitConfig struct {
|
|||||||
OverrideGpg bool `yaml:"overrideGpg"`
|
OverrideGpg bool `yaml:"overrideGpg"`
|
||||||
DisableForcePushing bool `yaml:"disableForcePushing"`
|
DisableForcePushing bool `yaml:"disableForcePushing"`
|
||||||
CommitPrefixes map[string]CommitPrefixConfig `yaml:"commitPrefixes"`
|
CommitPrefixes map[string]CommitPrefixConfig `yaml:"commitPrefixes"`
|
||||||
ParseEmoji bool `yaml:"parseEmoji"`
|
// this shoudl really be under 'gui', not 'git'
|
||||||
|
ParseEmoji bool `yaml:"parseEmoji"`
|
||||||
|
Log LogConfig `yaml:"log"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PagingConfig struct {
|
type PagingConfig struct {
|
||||||
@ -83,6 +85,11 @@ type MergingConfig struct {
|
|||||||
Args string `yaml:"args"`
|
Args string `yaml:"args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LogConfig struct {
|
||||||
|
Order string `yaml:"order"` // one of date-order, reverse, author-date-order, topo-order
|
||||||
|
ShowGraph string `yaml:"showGraph"` // one of always, never, when-maximised
|
||||||
|
}
|
||||||
|
|
||||||
type CommitPrefixConfig struct {
|
type CommitPrefixConfig struct {
|
||||||
Pattern string `yaml:"pattern"`
|
Pattern string `yaml:"pattern"`
|
||||||
Replace string `yaml:"replace"`
|
Replace string `yaml:"replace"`
|
||||||
@ -338,6 +345,10 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
ManualCommit: false,
|
ManualCommit: false,
|
||||||
Args: "",
|
Args: "",
|
||||||
},
|
},
|
||||||
|
Log: LogConfig{
|
||||||
|
Order: "topo-order",
|
||||||
|
ShowGraph: "when-maximised",
|
||||||
|
},
|
||||||
SkipHookPrefix: "WIP",
|
SkipHookPrefix: "WIP",
|
||||||
AutoFetch: true,
|
AutoFetch: true,
|
||||||
BranchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --",
|
BranchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
@ -173,6 +175,7 @@ func (gui *Gui) branchCommitsListContext() IListContext {
|
|||||||
selectedCommitSha,
|
selectedCommitSha,
|
||||||
startIdx,
|
startIdx,
|
||||||
length,
|
length,
|
||||||
|
gui.shouldShowGraph(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
SelectedItem: func() (ListItem, bool) {
|
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 {
|
func (gui *Gui) reflogCommitsListContext() IListContext {
|
||||||
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
parseEmoji := gui.Config.GetUserConfig().Git.ParseEmoji
|
||||||
return &ListContext{
|
return &ListContext{
|
||||||
@ -242,6 +260,7 @@ func (gui *Gui) subCommitsListContext() IListContext {
|
|||||||
selectedCommitSha,
|
selectedCommitSha,
|
||||||
0,
|
0,
|
||||||
len(gui.State.SubCommits),
|
len(gui.State.SubCommits),
|
||||||
|
gui.shouldShowGraph(),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
SelectedItem: func() (ListItem, bool) {
|
SelectedItem: func() (ListItem, bool) {
|
||||||
|
@ -30,6 +30,7 @@ func GetCommitListDisplayStrings(
|
|||||||
selectedCommitSha string,
|
selectedCommitSha string,
|
||||||
startIdx int,
|
startIdx int,
|
||||||
length int,
|
length int,
|
||||||
|
showGraph bool,
|
||||||
) [][]string {
|
) [][]string {
|
||||||
mutex.Lock()
|
mutex.Lock()
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
@ -61,13 +62,20 @@ func GetCommitListDisplayStrings(
|
|||||||
end = len(commits) - 1
|
end = len(commits) - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredPipeSets := pipeSets[startIdx : end+1]
|
|
||||||
filteredCommits := commits[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 {
|
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
|
return lines
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user