1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-27 05:01:50 +03:00

Un-deprecate UserConfig.Git.Log.Order and ShowGraph

And remove them from AppState.
This commit is contained in:
Stefan Haller
2025-07-07 17:14:55 +02:00
parent 703256e92d
commit 562a2aaa6b
28 changed files with 46 additions and 59 deletions

View File

@ -396,6 +396,19 @@ git:
# Config for showing the log in the commits view # Config for showing the log in the commits view
log: log:
# 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/
#
# Can be changed from within Lazygit with `Log menu -> Commit sort order` (`<c-l>` in the commits window by default).
order: topo-order
# This determines whether the git graph is rendered in the commits panel
# One of 'always' | 'never' | 'when-maximised'
#
# Can be toggled from within lazygit with `Log menu -> Show git graph` (`<c-l>` in the commits window by default).
showGraph: always
# 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: false showWholeGraph: false

View File

@ -583,7 +583,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.CmdObj { func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj {
gitLogOrder := self.AppState.GitLogOrder gitLogOrder := self.UserConfig().Git.Log.Order
refSpec := opts.RefName refSpec := opts.RefName
if opts.RefToShowDivergenceFrom != "" { if opts.RefToShowDivergenceFrom != "" {

View File

@ -9,7 +9,6 @@ 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/common" "github.com/jesseduffield/lazygit/pkg/common"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils" "github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo" "github.com/samber/lo"
"github.com/stefanhaller/git-todo-parser/todo" "github.com/stefanhaller/git-todo-parser/todo"
@ -298,8 +297,7 @@ func TestGetCommits(t *testing.T) {
for _, scenario := range scenarios { for _, scenario := range scenarios {
t.Run(scenario.testName, func(t *testing.T) { t.Run(scenario.testName, func(t *testing.T) {
common := common.NewDummyCommon() common := common.NewDummyCommon()
common.AppState = &config.AppState{} common.UserConfig().Git.Log.Order = scenario.logOrder
common.AppState.GitLogOrder = scenario.logOrder
cmd := oscommands.NewDummyCmdObjBuilder(scenario.runner) cmd := oscommands.NewDummyCmdObjBuilder(scenario.runner)
builder := &CommitLoader{ builder := &CommitLoader{

View File

@ -107,17 +107,6 @@ 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,
@ -677,15 +666,6 @@ type AppState struct {
ShellCommandsHistory []string `yaml:"customcommandshistory"` ShellCommandsHistory []string `yaml:"customcommandshistory"`
HideCommandLog bool HideCommandLog bool
// 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 {
@ -694,8 +674,6 @@ func getDefaultAppState() *AppState {
RecentRepos: []string{}, RecentRepos: []string{},
StartupPopupVersion: 0, StartupPopupVersion: 0,
LastVersion: "", LastVersion: "",
GitLogOrder: "", // should be "topo-order" eventually
GitLogShowGraph: "", // should be "always" eventually
} }
} }

View File

@ -346,13 +346,13 @@ type LogConfig struct {
// '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/
// //
// Deprecated: Configure this with `Log menu -> Commit sort order` (<c-l> in the commits window by default). // Can be changed from within Lazygit 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"` Order string `yaml:"order" jsonschema:"enum=date-order,enum=author-date-order,enum=topo-order,enum=default"`
// 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'
// //
// Deprecated: Configure this with `Log menu -> Show git graph` (<c-l> in the commits window by default). // Can be toggled from within lazygit 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"` ShowGraph string `yaml:"showGraph" jsonschema:"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"`
} }

View File

@ -251,7 +251,7 @@ func shouldShowGraph(c *ContextCommon) bool {
return false return false
} }
value := c.GetAppState().GitLogShowGraph value := c.UserConfig().Git.Log.ShowGraph
switch value { switch value {
case "always": case "always":

View File

@ -1182,11 +1182,10 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
Label: self.c.Tr.ShowGitGraph, Label: self.c.Tr.ShowGitGraph,
OpensMenu: true, OpensMenu: true,
OnPress: func() error { OnPress: func() error {
currentValue := self.c.GetAppState().GitLogShowGraph currentValue := self.c.UserConfig().Git.Log.ShowGraph
onPress := func(value string) func() error { onPress := func(value string) func() error {
return func() error { return func() error {
self.c.GetAppState().GitLogShowGraph = value self.c.UserConfig().Git.Log.ShowGraph = value
self.c.SaveAppStateAndLogError()
self.c.PostRefreshUpdate(self.c.Contexts().LocalCommits) self.c.PostRefreshUpdate(self.c.Contexts().LocalCommits)
self.c.PostRefreshUpdate(self.c.Contexts().SubCommits) self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)
return nil return nil
@ -1218,11 +1217,10 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
Label: self.c.Tr.SortCommits, Label: self.c.Tr.SortCommits,
OpensMenu: true, OpensMenu: true,
OnPress: func() error { OnPress: func() error {
currentValue := self.c.GetAppState().GitLogOrder currentValue := self.c.UserConfig().Git.Log.Order
onPress := func(value string) func() error { onPress := func(value string) func() error {
return func() error { return func() error {
self.c.GetAppState().GitLogOrder = value self.c.UserConfig().Git.Log.Order = 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 {
self.c.Refresh( self.c.Refresh(
types.RefreshOptions{ types.RefreshOptions{

View File

@ -15,7 +15,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
CreateNCommits(10) CreateNCommits(10)
}, },
SetupConfig: func(cfg *config.AppConfig) { SetupConfig: func(cfg *config.AppConfig) {
cfg.GetAppState().GitLogShowGraph = "never" cfg.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
Run: func(t *TestDriver, keys config.KeybindingConfig) { Run: func(t *TestDriver, keys config.KeybindingConfig) {
markCommitAsBad := func() { markCommitAsBad := func() {

View File

@ -15,7 +15,7 @@ var ChooseTerms = NewIntegrationTest(NewIntegrationTestArgs{
CreateNCommits(10) CreateNCommits(10)
}, },
SetupConfig: func(cfg *config.AppConfig) { SetupConfig: func(cfg *config.AppConfig) {
cfg.GetAppState().GitLogShowGraph = "never" cfg.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
Run: func(t *TestDriver, keys config.KeybindingConfig) { Run: func(t *TestDriver, keys config.KeybindingConfig) {
markCommitAsFixed := func() { markCommitAsFixed := func() {

View File

@ -14,7 +14,7 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{
CreateNCommits(10) CreateNCommits(10)
}, },
SetupConfig: func(cfg *config.AppConfig) { SetupConfig: func(cfg *config.AppConfig) {
cfg.GetAppState().GitLogShowGraph = "never" cfg.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
Run: func(t *TestDriver, keys config.KeybindingConfig) { Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits(). t.Views().Commits().

View File

@ -11,7 +11,7 @@ var RebaseCopiedBranch = 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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
config.GetUserConfig().Git.LocalBranchSortOrder = "recency" config.GetUserConfig().Git.LocalBranchSortOrder = "recency"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {

View File

@ -11,7 +11,7 @@ var DoNotShowBranchMarkerForHeadCommit = NewIntegrationTest(NewIntegrationTestAr
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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell.EmptyCommit("one") shell.EmptyCommit("one")

View File

@ -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.GetAppState().GitLogShowGraph = "always" config.GetUserConfig().Git.Log.ShowGraph = "always"
config.GetUserConfig().Gui.AuthorColors = map[string]string{ config.GetUserConfig().Gui.AuthorColors = map[string]string{
"CI": "red", "CI": "red",
} }

View File

@ -10,7 +10,7 @@ var SelectAuthor = NewIntegrationTest(NewIntegrationTestArgs{
ExtraCmdArgs: []string{}, ExtraCmdArgs: []string{},
Skip: false, Skip: false,
SetupConfig: func(config *config.AppConfig) { SetupConfig: func(config *config.AppConfig) {
config.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
commonSetup(shell) commonSetup(shell)

View File

@ -11,7 +11,7 @@ var DontShowBranchHeadsForTodoItems = 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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -11,7 +11,7 @@ var DropCommitInCopiedBranchWithUpdateRef = NewIntegrationTest(NewIntegrationTes
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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -12,7 +12,7 @@ var EditLastCommitOfStackedBranch = 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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -11,7 +11,7 @@ var InteractiveRebaseOfCopiedBranch = 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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -12,7 +12,7 @@ var MoveAcrossBranchBoundaryOutsideRebase = NewIntegrationTest(NewIntegrationTes
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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -12,7 +12,7 @@ var RewordLastCommitOfStackedBranch = 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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -11,7 +11,7 @@ var MoveToNewCommitInLastCommitOfStackedBranch = NewIntegrationTest(NewIntegrati
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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell. shell.

View File

@ -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.GetAppState().GitLogShowGraph = "never" config.GetUserConfig().Git.Log.ShowGraph = "never"
}, },
SetupRepo: func(shell *Shell) { SetupRepo: func(shell *Shell) {
shell.NewBranch("branch1") shell.NewBranch("branch1")

View File

@ -1532,7 +1532,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/\n\nDeprecated: Configure this with `Log menu -\u003e Commit sort order` (\u003cc-l\u003e in the commits window by 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/\n\nCan be changed from within Lazygit with `Log menu -\u003e Commit sort order` (`\u003cc-l\u003e` in the commits window by default).",
"default": "topo-order" "default": "topo-order"
}, },
"showGraph": { "showGraph": {
@ -1542,7 +1542,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'\n\nDeprecated: Configure this with `Log menu -\u003e Show git graph` (\u003cc-l\u003e in the commits window by default).", "description": "This determines whether the git graph is rendered in the commits panel\nOne of 'always' | 'never' | 'when-maximised'\n\nCan be toggled from within lazygit with `Log menu -\u003e Show git graph` (`\u003cc-l\u003e` in the commits window by default).",
"default": "always" "default": "always"
}, },
"showWholeGraph": { "showWholeGraph": {