refactoring the config struct

This commit is contained in:
Jesse Duffield
2021-12-29 12:03:35 +11:00
parent 01ea5813a8
commit 192a548c99
9 changed files with 26 additions and 40 deletions

View File

@@ -4,7 +4,6 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/updates"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -12,7 +11,7 @@ import (
// NewDummyGui creates a new dummy GUI for testing
func NewDummyUpdater() *updates.Updater {
newAppConfig := config.NewDummyAppConfig()
dummyUpdater, _ := updates.NewUpdater(utils.NewDummyLog(), newAppConfig, oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language))
dummyUpdater, _ := updates.NewUpdater(utils.NewDummyCommon(), newAppConfig, oscommands.NewDummyOSCommand())
return dummyUpdater
}

View File

@@ -432,6 +432,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) {
// for now the split view will always be on
// NewGui builds a new gui handler
func NewGui(cmn *common.Common, gitCommand *commands.GitCommand, oSCommand *oscommands.OSCommand, config config.AppConfigurer, updater *updates.Updater, filterPath string, showRecentRepos bool) (*Gui, error) {
gui := &Gui{
Common: cmn,
GitCommand: gitCommand,
@@ -444,8 +445,12 @@ func NewGui(cmn *common.Common, gitCommand *commands.GitCommand, oSCommand *osco
RepoPathStack: []string{},
RepoStateMap: map[Repo]*guiState{},
CmdLog: []string{},
ShowExtrasWindow: config.ShowCommandLogOnStartup(),
suggestionsAsyncHandler: tasks.NewAsyncHandler(),
// originally we could only hide the command log permanently via the config
// but now we do it via state. So we need to still support the config for the
// sake of backwards compatibility. We're making use of short circuiting here
ShowExtrasWindow: cmn.UserConfig.Gui.ShowCommandLog && !config.GetAppState().HideCommandLog,
}
gui.resetState(filterPath, false)

View File

@@ -73,7 +73,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
return err
}
newGitCommand, err := commands.NewGitCommand(gui.Common, gui.OSCommand, gui.Config, git_config.NewStdCachedGitConfig(gui.Log))
newGitCommand, err := commands.NewGitCommand(gui.Common, gui.OSCommand, git_config.NewStdCachedGitConfig(gui.Log))
if err != nil {
return err
}