Skip to content

Commit 562a2aa

Browse files
committed
Un-deprecate UserConfig.Git.Log.Order and ShowGraph
And remove them from AppState.
1 parent 703256e commit 562a2aa

28 files changed

+46
-59
lines changed

docs/Config.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,19 @@ git:
396396

397397
# Config for showing the log in the commits view
398398
log:
399+
# One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default'
400+
# 'topo-order' makes it easier to read the git log graph, but commits may not
401+
# appear chronologically. See https://git-scm.com/docs/
402+
#
403+
# Can be changed from within Lazygit with `Log menu -> Commit sort order` (`<c-l>` in the commits window by default).
404+
order: topo-order
405+
406+
# This determines whether the git graph is rendered in the commits panel
407+
# One of 'always' | 'never' | 'when-maximised'
408+
#
409+
# Can be toggled from within lazygit with `Log menu -> Show git graph` (`<c-l>` in the commits window by default).
410+
showGraph: always
411+
399412
# displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
400413
showWholeGraph: false
401414

pkg/commands/git_commands/commit_loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ func (self *CommitLoader) getFirstPushedCommit(refName string) (string, error) {
583583

584584
// getLog gets the git log.
585585
func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj {
586-
gitLogOrder := self.AppState.GitLogOrder
586+
gitLogOrder := self.UserConfig().Git.Log.Order
587587

588588
refSpec := opts.RefName
589589
if opts.RefToShowDivergenceFrom != "" {

pkg/commands/git_commands/commit_loader_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/jesseduffield/lazygit/pkg/commands/models"
1010
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
1111
"github.com/jesseduffield/lazygit/pkg/common"
12-
"github.com/jesseduffield/lazygit/pkg/config"
1312
"github.com/jesseduffield/lazygit/pkg/utils"
1413
"github.com/samber/lo"
1514
"github.com/stefanhaller/git-todo-parser/todo"
@@ -298,8 +297,7 @@ func TestGetCommits(t *testing.T) {
298297
for _, scenario := range scenarios {
299298
t.Run(scenario.testName, func(t *testing.T) {
300299
common := common.NewDummyCommon()
301-
common.AppState = &config.AppState{}
302-
common.AppState.GitLogOrder = scenario.logOrder
300+
common.UserConfig().Git.Log.Order = scenario.logOrder
303301
cmd := oscommands.NewDummyCmdObjBuilder(scenario.runner)
304302

305303
builder := &CommitLoader{

pkg/config/app_config.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,6 @@ func NewAppConfig(
107107
return nil, err
108108
}
109109

110-
// Temporary: the defaults for these are set to empty strings in
111-
// getDefaultAppState so that we can migrate them from userConfig (which is
112-
// now deprecated). Once we remove the user configs, we can remove this code
113-
// and set the proper defaults in getDefaultAppState.
114-
if appState.GitLogOrder == "" {
115-
appState.GitLogOrder = userConfig.Git.Log.Order
116-
}
117-
if appState.GitLogShowGraph == "" {
118-
appState.GitLogShowGraph = userConfig.Git.Log.ShowGraph
119-
}
120-
121110
appConfig := &AppConfig{
122111
name: name,
123112
version: version,
@@ -677,15 +666,6 @@ type AppState struct {
677666
ShellCommandsHistory []string `yaml:"customcommandshistory"`
678667

679668
HideCommandLog bool
680-
681-
// One of: 'date-order' | 'author-date-order' | 'topo-order' | 'default'
682-
// 'topo-order' makes it easier to read the git log graph, but commits may not
683-
// appear chronologically. See https://git-scm.com/docs/
684-
GitLogOrder string
685-
686-
// This determines whether the git graph is rendered in the commits panel
687-
// One of 'always' | 'never' | 'when-maximised'
688-
GitLogShowGraph string
689669
}
690670

691671
func getDefaultAppState() *AppState {
@@ -694,8 +674,6 @@ func getDefaultAppState() *AppState {
694674
RecentRepos: []string{},
695675
StartupPopupVersion: 0,
696676
LastVersion: "",
697-
GitLogOrder: "", // should be "topo-order" eventually
698-
GitLogShowGraph: "", // should be "always" eventually
699677
}
700678
}
701679

pkg/config/user_config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,13 @@ type LogConfig struct {
346346
// 'topo-order' makes it easier to read the git log graph, but commits may not
347347
// appear chronologically. See https://git-scm.com/docs/
348348
//
349-
// Deprecated: Configure this with `Log menu -> Commit sort order` (<c-l> in the commits window by default).
350-
Order string `yaml:"order" jsonschema:"deprecated,enum=date-order,enum=author-date-order,enum=topo-order,enum=default,deprecated"`
349+
// Can be changed from within Lazygit with `Log menu -> Commit sort order` (`<c-l>` in the commits window by default).
350+
Order string `yaml:"order" jsonschema:"enum=date-order,enum=author-date-order,enum=topo-order,enum=default"`
351351
// This determines whether the git graph is rendered in the commits panel
352352
// One of 'always' | 'never' | 'when-maximised'
353353
//
354-
// Deprecated: Configure this with `Log menu -> Show git graph` (<c-l> in the commits window by default).
355-
ShowGraph string `yaml:"showGraph" jsonschema:"deprecated,enum=always,enum=never,enum=when-maximised"`
354+
// Can be toggled from within lazygit with `Log menu -> Show git graph` (`<c-l>` in the commits window by default).
355+
ShowGraph string `yaml:"showGraph" jsonschema:"enum=always,enum=never,enum=when-maximised"`
356356
// displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
357357
ShowWholeGraph bool `yaml:"showWholeGraph"`
358358
}

pkg/gui/context/local_commits_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ func shouldShowGraph(c *ContextCommon) bool {
251251
return false
252252
}
253253

254-
value := c.GetAppState().GitLogShowGraph
254+
value := c.UserConfig().Git.Log.ShowGraph
255255

256256
switch value {
257257
case "always":

pkg/gui/controllers/local_commits_controller.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,10 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
11821182
Label: self.c.Tr.ShowGitGraph,
11831183
OpensMenu: true,
11841184
OnPress: func() error {
1185-
currentValue := self.c.GetAppState().GitLogShowGraph
1185+
currentValue := self.c.UserConfig().Git.Log.ShowGraph
11861186
onPress := func(value string) func() error {
11871187
return func() error {
1188-
self.c.GetAppState().GitLogShowGraph = value
1189-
self.c.SaveAppStateAndLogError()
1188+
self.c.UserConfig().Git.Log.ShowGraph = value
11901189
self.c.PostRefreshUpdate(self.c.Contexts().LocalCommits)
11911190
self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)
11921191
return nil
@@ -1218,11 +1217,10 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
12181217
Label: self.c.Tr.SortCommits,
12191218
OpensMenu: true,
12201219
OnPress: func() error {
1221-
currentValue := self.c.GetAppState().GitLogOrder
1220+
currentValue := self.c.UserConfig().Git.Log.Order
12221221
onPress := func(value string) func() error {
12231222
return func() error {
1224-
self.c.GetAppState().GitLogOrder = value
1225-
self.c.SaveAppStateAndLogError()
1223+
self.c.UserConfig().Git.Log.Order = value
12261224
return self.c.WithWaitingStatus(self.c.Tr.LoadingCommits, func(gocui.Task) error {
12271225
self.c.Refresh(
12281226
types.RefreshOptions{

pkg/integration/tests/bisect/basic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var Basic = NewIntegrationTest(NewIntegrationTestArgs{
1515
CreateNCommits(10)
1616
},
1717
SetupConfig: func(cfg *config.AppConfig) {
18-
cfg.GetAppState().GitLogShowGraph = "never"
18+
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
1919
},
2020
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2121
markCommitAsBad := func() {

pkg/integration/tests/bisect/choose_terms.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var ChooseTerms = NewIntegrationTest(NewIntegrationTestArgs{
1515
CreateNCommits(10)
1616
},
1717
SetupConfig: func(cfg *config.AppConfig) {
18-
cfg.GetAppState().GitLogShowGraph = "never"
18+
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
1919
},
2020
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2121
markCommitAsFixed := func() {

pkg/integration/tests/bisect/skip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var Skip = NewIntegrationTest(NewIntegrationTestArgs{
1414
CreateNCommits(10)
1515
},
1616
SetupConfig: func(cfg *config.AppConfig) {
17-
cfg.GetAppState().GitLogShowGraph = "never"
17+
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
1818
},
1919
Run: func(t *TestDriver, keys config.KeybindingConfig) {
2020
t.Views().Commits().

0 commit comments

Comments
 (0)