mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
Deprecate git.log.showGraph and git.log.order config
Added identical properties to AppState that should eventually have their defaults set.
This commit is contained in:
parent
b01bad7fad
commit
e354a9bb48
@ -101,9 +101,13 @@ git:
|
|||||||
# one of date-order, author-date-order, topo-order or default.
|
# one of date-order, author-date-order, topo-order or default.
|
||||||
# topo-order makes it easier to read the git log graph, but commits may not
|
# 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
|
# appear chronologically. See https://git-scm.com/docs/git-log#_commit_ordering
|
||||||
|
#
|
||||||
|
# Deprecated: Configure this with `Log menu -> Commit sort order` (<c-l> in the commits window by default).
|
||||||
order: 'topo-order'
|
order: 'topo-order'
|
||||||
# one of always, never, when-maximised
|
# one of always, never, when-maximised
|
||||||
# this determines whether the git graph is rendered in the commits panel
|
# this determines whether the git graph is rendered in the commits panel
|
||||||
|
#
|
||||||
|
# Deprecated: Configure this with `Log menu -> Show git graph` (<c-l> in the commits window by default).
|
||||||
showGraph: 'always'
|
showGraph: 'always'
|
||||||
# displays the whole git graph by default in the commits panel (equivalent to passing the `--all` argument to `git log`)
|
# displays the whole git graph by default in the commits panel (equivalent to passing the `--all` argument to `git log`)
|
||||||
showWholeGraph: false
|
showWholeGraph: false
|
||||||
|
@ -650,7 +650,7 @@ func (self *CommitLoader) getFirstPushedCommit(refName string) (string, error) {
|
|||||||
|
|
||||||
// getLog gets the git log.
|
// getLog gets the git log.
|
||||||
func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
||||||
config := self.UserConfig.Git.Log
|
gitLogOrder := self.AppState.GitLogOrder
|
||||||
|
|
||||||
refSpec := opts.RefName
|
refSpec := opts.RefName
|
||||||
if opts.RefToShowDivergenceFrom != "" {
|
if opts.RefToShowDivergenceFrom != "" {
|
||||||
@ -659,7 +659,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
|||||||
|
|
||||||
cmdArgs := NewGitCmd("log").
|
cmdArgs := NewGitCmd("log").
|
||||||
Arg(refSpec).
|
Arg(refSpec).
|
||||||
ArgIf(config.Order != "default", "--"+config.Order).
|
ArgIf(gitLogOrder != "default", "--"+gitLogOrder).
|
||||||
ArgIf(opts.All, "--all").
|
ArgIf(opts.All, "--all").
|
||||||
Arg("--oneline").
|
Arg("--oneline").
|
||||||
Arg(prettyFormat).
|
Arg(prettyFormat).
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
@ -305,7 +306,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
scenario := scenario
|
scenario := scenario
|
||||||
t.Run(scenario.testName, func(t *testing.T) {
|
t.Run(scenario.testName, func(t *testing.T) {
|
||||||
common := utils.NewDummyCommon()
|
common := utils.NewDummyCommon()
|
||||||
common.UserConfig.Git.Log.Order = scenario.logOrder
|
common.AppState = &config.AppState{}
|
||||||
|
common.AppState.GitLogOrder = scenario.logOrder
|
||||||
|
|
||||||
builder := &CommitLoader{
|
builder := &CommitLoader{
|
||||||
Common: common,
|
Common: common,
|
||||||
|
@ -80,6 +80,17 @@ func NewAppConfig(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary: the defaults for these are set to empty strings in
|
||||||
|
// getDefaultAppState so that we can migrate them from userConfig (which is
|
||||||
|
// now deprecated). Once we remove the user configs, we can remove this code
|
||||||
|
// and set the proper defaults in getDefaultAppState.
|
||||||
|
if appState.GitLogOrder == "" {
|
||||||
|
appState.GitLogOrder = userConfig.Git.Log.Order
|
||||||
|
}
|
||||||
|
if appState.GitLogShowGraph == "" {
|
||||||
|
appState.GitLogShowGraph = userConfig.Git.Log.ShowGraph
|
||||||
|
}
|
||||||
|
|
||||||
appConfig := &AppConfig{
|
appConfig := &AppConfig{
|
||||||
Name: name,
|
Name: name,
|
||||||
Version: version,
|
Version: version,
|
||||||
@ -325,6 +336,15 @@ type AppState struct {
|
|||||||
DiffContextSize int
|
DiffContextSize int
|
||||||
LocalBranchSortOrder string
|
LocalBranchSortOrder string
|
||||||
RemoteBranchSortOrder string
|
RemoteBranchSortOrder string
|
||||||
|
|
||||||
|
// One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default'
|
||||||
|
// 'topo-order' makes it easier to read the git log graph, but commits may not
|
||||||
|
// appear chronologically. See https://git-scm.com/docs/
|
||||||
|
GitLogOrder string
|
||||||
|
|
||||||
|
// This determines whether the git graph is rendered in the commits panel
|
||||||
|
// One of 'always' | 'never' | 'when-maximised'
|
||||||
|
GitLogShowGraph string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDefaultAppState() *AppState {
|
func getDefaultAppState() *AppState {
|
||||||
@ -335,6 +355,8 @@ func getDefaultAppState() *AppState {
|
|||||||
DiffContextSize: 3,
|
DiffContextSize: 3,
|
||||||
LocalBranchSortOrder: "recency",
|
LocalBranchSortOrder: "recency",
|
||||||
RemoteBranchSortOrder: "alphabetical",
|
RemoteBranchSortOrder: "alphabetical",
|
||||||
|
GitLogOrder: "", // should be "topo-order" eventually
|
||||||
|
GitLogShowGraph: "", // should be "always" eventually
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,13 +247,17 @@ type MergingConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LogConfig struct {
|
type LogConfig struct {
|
||||||
// One of: 'date-order' | 'author-date-order' | 'topo-order | default'
|
// One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default'
|
||||||
// 'topo-order' makes it easier to read the git log graph, but commits may not
|
// 'topo-order' makes it easier to read the git log graph, but commits may not
|
||||||
// appear chronologically. See https://git-scm.com/docs/
|
// appear chronologically. See https://git-scm.com/docs/
|
||||||
Order string `yaml:"order" jsonschema:"enum=date-order,enum=author-date-order,enum=topo-order,enum=default"`
|
//
|
||||||
|
// Deprecated: Configure this with `Log menu -> Commit sort order` (<c-l> in the commits window by default).
|
||||||
|
Order string `yaml:"order" jsonschema:"deprecated,enum=date-order,enum=author-date-order,enum=topo-order,enum=default,deprecated"`
|
||||||
// This determines whether the git graph is rendered in the commits panel
|
// This determines whether the git graph is rendered in the commits panel
|
||||||
// One of 'always' | 'never' | 'when-maximised'
|
// One of 'always' | 'never' | 'when-maximised'
|
||||||
ShowGraph string `yaml:"showGraph" jsonschema:"enum=always,enum=never,enum=when-maximised"`
|
//
|
||||||
|
// Deprecated: Configure this with `Log menu -> Show git graph` (<c-l> in the commits window by default).
|
||||||
|
ShowGraph string `yaml:"showGraph" jsonschema:"deprecated,enum=always,enum=never,enum=when-maximised"`
|
||||||
// displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
|
// displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
|
||||||
ShowWholeGraph bool `yaml:"showWholeGraph"`
|
ShowWholeGraph bool `yaml:"showWholeGraph"`
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,8 @@ func shouldShowGraph(c *ContextCommon) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
value := c.UserConfig.Git.Log.ShowGraph
|
value := c.GetAppState().GitLogShowGraph
|
||||||
|
|
||||||
switch value {
|
switch value {
|
||||||
case "always":
|
case "always":
|
||||||
return true
|
return true
|
||||||
|
@ -928,7 +928,8 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
onPress := func(value string) func() error {
|
onPress := func(value string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
self.c.UserConfig.Git.Log.ShowGraph = value
|
self.c.GetAppState().GitLogShowGraph = value
|
||||||
|
self.c.SaveAppStateAndLogError()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -957,7 +958,8 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
onPress := func(value string) func() error {
|
onPress := func(value string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
self.c.UserConfig.Git.Log.Order = value
|
self.c.GetAppState().GitLogOrder = value
|
||||||
|
self.c.SaveAppStateAndLogError()
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.LoadingCommits, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.LoadingCommits, func(gocui.Task) error {
|
||||||
return self.c.Refresh(
|
return self.c.Refresh(
|
||||||
types.RefreshOptions{
|
types.RefreshOptions{
|
||||||
|
@ -15,7 +15,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateNCommits(10)
|
CreateNCommits(10)
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {
|
SetupConfig: func(cfg *config.AppConfig) {
|
||||||
cfg.UserConfig.Git.Log.ShowGraph = "never"
|
cfg.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
markCommitAsBad := func() {
|
markCommitAsBad := func() {
|
||||||
|
@ -15,7 +15,7 @@ var ChooseTerms = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateNCommits(10)
|
CreateNCommits(10)
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {
|
SetupConfig: func(cfg *config.AppConfig) {
|
||||||
cfg.UserConfig.Git.Log.ShowGraph = "never"
|
cfg.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
markCommitAsFixed := func() {
|
markCommitAsFixed := func() {
|
||||||
|
@ -14,7 +14,7 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
CreateNCommits(10)
|
CreateNCommits(10)
|
||||||
},
|
},
|
||||||
SetupConfig: func(cfg *config.AppConfig) {
|
SetupConfig: func(cfg *config.AppConfig) {
|
||||||
cfg.UserConfig.Git.Log.ShowGraph = "never"
|
cfg.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||||
t.Views().Commits().
|
t.Views().Commits().
|
||||||
|
@ -10,7 +10,7 @@ var CherryPickDuringRebase = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
ExtraCmdArgs: []string{},
|
ExtraCmdArgs: []string{},
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.
|
shell.
|
||||||
|
@ -10,7 +10,7 @@ var Highlight = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
ExtraCmdArgs: []string{},
|
ExtraCmdArgs: []string{},
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.GetUserConfig().Git.Log.ShowGraph = "always"
|
config.AppState.GitLogShowGraph = "always"
|
||||||
config.GetUserConfig().Gui.AuthorColors = map[string]string{
|
config.GetUserConfig().Gui.AuthorColors = map[string]string{
|
||||||
"CI": "red",
|
"CI": "red",
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
GitVersion: AtLeast("2.38.0"),
|
GitVersion: AtLeast("2.38.0"),
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.
|
shell.
|
||||||
|
@ -12,7 +12,7 @@ var QuickStartKeepSelection = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
GitVersion: AtLeast("2.38.0"),
|
GitVersion: AtLeast("2.38.0"),
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.
|
shell.
|
||||||
|
@ -12,7 +12,7 @@ var QuickStartKeepSelectionRange = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
GitVersion: AtLeast("2.38.0"),
|
GitVersion: AtLeast("2.38.0"),
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
config.GetUserConfig().Git.MainBranches = []string{"master"}
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.
|
shell.
|
||||||
|
@ -11,7 +11,7 @@ var ViewFilesOfTodoEntries = NewIntegrationTest(NewIntegrationTestArgs{
|
|||||||
Skip: false,
|
Skip: false,
|
||||||
GitVersion: AtLeast("2.38.0"),
|
GitVersion: AtLeast("2.38.0"),
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.
|
shell.
|
||||||
|
@ -10,7 +10,7 @@ var DoNotShowBranchMarkersInReflogSubcommits = NewIntegrationTest(NewIntegration
|
|||||||
ExtraCmdArgs: []string{},
|
ExtraCmdArgs: []string{},
|
||||||
Skip: false,
|
Skip: false,
|
||||||
SetupConfig: func(config *config.AppConfig) {
|
SetupConfig: func(config *config.AppConfig) {
|
||||||
config.UserConfig.Git.Log.ShowGraph = "never"
|
config.AppState.GitLogShowGraph = "never"
|
||||||
},
|
},
|
||||||
SetupRepo: func(shell *Shell) {
|
SetupRepo: func(shell *Shell) {
|
||||||
shell.NewBranch("branch1")
|
shell.NewBranch("branch1")
|
||||||
|
@ -519,7 +519,7 @@
|
|||||||
"topo-order",
|
"topo-order",
|
||||||
"default"
|
"default"
|
||||||
],
|
],
|
||||||
"description": "One of: 'date-order' | 'author-date-order' | 'topo-order | default'\n'topo-order' makes it easier to read the git log graph, but commits may not\nappear chronologically. See https://git-scm.com/docs/",
|
"description": "One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default'\n'topo-order' makes it easier to read the git log graph, but commits may not\nappear chronologically. See https://git-scm.com/docs/\n\nDeprecated: Configure this with `Log menu -\u003e Commit sort order` (\u003cc-l\u003e in the commits window by default).",
|
||||||
"default": "topo-order"
|
"default": "topo-order"
|
||||||
},
|
},
|
||||||
"showGraph": {
|
"showGraph": {
|
||||||
@ -529,7 +529,7 @@
|
|||||||
"never",
|
"never",
|
||||||
"when-maximised"
|
"when-maximised"
|
||||||
],
|
],
|
||||||
"description": "This determines whether the git graph is rendered in the commits panel\nOne of 'always' | 'never' | 'when-maximised'",
|
"description": "This determines whether the git graph is rendered in the commits panel\nOne of 'always' | 'never' | 'when-maximised'\n\nDeprecated: Configure this with `Log menu -\u003e Show git graph` (\u003cc-l\u003e in the commits window by default).",
|
||||||
"default": "always"
|
"default": "always"
|
||||||
},
|
},
|
||||||
"showWholeGraph": {
|
"showWholeGraph": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user