1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-31 22:22:14 +02:00

Add AppState to common.Common

This commit is contained in:
Stefan Haller 2023-08-28 12:24:58 +02:00
parent e895052437
commit 18c5780485
4 changed files with 7 additions and 2 deletions

View File

@ -62,6 +62,7 @@ func Run(
func NewCommon(config config.AppConfigurer) (*common.Common, error) { func NewCommon(config config.AppConfigurer) (*common.Common, error) {
userConfig := config.GetUserConfig() userConfig := config.GetUserConfig()
appState := config.GetAppState()
var err error var err error
log := newLogger(config) log := newLogger(config)
@ -74,6 +75,7 @@ func NewCommon(config config.AppConfigurer) (*common.Common, error) {
Log: log, Log: log,
Tr: tr, Tr: tr,
UserConfig: userConfig, UserConfig: userConfig,
AppState: appState,
Debug: config.GetDebug(), Debug: config.GetDebug(),
Fs: afero.NewOsFs(), Fs: afero.NewOsFs(),
}, nil }, nil

View File

@ -17,6 +17,7 @@ import (
type commonDeps struct { type commonDeps struct {
runner *oscommands.FakeCmdObjRunner runner *oscommands.FakeCmdObjRunner
userConfig *config.UserConfig userConfig *config.UserConfig
appState *config.AppState
gitVersion *GitVersion gitVersion *GitVersion
gitConfig *git_config.FakeGitConfig gitConfig *git_config.FakeGitConfig
getenv func(string) string getenv func(string) string
@ -32,7 +33,7 @@ func buildGitCommon(deps commonDeps) *GitCommon {
gitCommon.Common = deps.common gitCommon.Common = deps.common
if gitCommon.Common == nil { if gitCommon.Common == nil {
gitCommon.Common = utils.NewDummyCommonWithUserConfig(deps.userConfig) gitCommon.Common = utils.NewDummyCommonWithUserConfigAndAppState(deps.userConfig, deps.appState)
} }
if deps.fs != nil { if deps.fs != nil {

View File

@ -12,6 +12,7 @@ type Common struct {
Log *logrus.Entry Log *logrus.Entry
Tr *i18n.TranslationSet Tr *i18n.TranslationSet
UserConfig *config.UserConfig UserConfig *config.UserConfig
AppState *config.AppState
Debug bool Debug bool
// for interacting with the filesystem. We use afero rather than the default // for interacting with the filesystem. We use afero rather than the default
// `os` package for the sake of mocking the filesystem in tests // `os` package for the sake of mocking the filesystem in tests

View File

@ -27,12 +27,13 @@ func NewDummyCommon() *common.Common {
} }
} }
func NewDummyCommonWithUserConfig(userConfig *config.UserConfig) *common.Common { func NewDummyCommonWithUserConfigAndAppState(userConfig *config.UserConfig, appState *config.AppState) *common.Common {
tr := i18n.EnglishTranslationSet() tr := i18n.EnglishTranslationSet()
return &common.Common{ return &common.Common{
Log: NewDummyLog(), Log: NewDummyLog(),
Tr: &tr, Tr: &tr,
UserConfig: userConfig, UserConfig: userConfig,
AppState: appState,
// TODO: remove dependency on actual filesystem in tests and switch to using // TODO: remove dependency on actual filesystem in tests and switch to using
// in-memory for everything // in-memory for everything
Fs: afero.NewOsFs(), Fs: afero.NewOsFs(),