1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-19 21:28:28 +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) {
userConfig := config.GetUserConfig()
appState := config.GetAppState()
var err error
log := newLogger(config)
@ -74,6 +75,7 @@ func NewCommon(config config.AppConfigurer) (*common.Common, error) {
Log: log,
Tr: tr,
UserConfig: userConfig,
AppState: appState,
Debug: config.GetDebug(),
Fs: afero.NewOsFs(),
}, nil

View File

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

View File

@ -12,6 +12,7 @@ type Common struct {
Log *logrus.Entry
Tr *i18n.TranslationSet
UserConfig *config.UserConfig
AppState *config.AppState
Debug bool
// for interacting with the filesystem. We use afero rather than the default
// `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()
return &common.Common{
Log: NewDummyLog(),
Tr: &tr,
UserConfig: userConfig,
AppState: appState,
// TODO: remove dependency on actual filesystem in tests and switch to using
// in-memory for everything
Fs: afero.NewOsFs(),