diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/app/app.go | 11 | ||||
-rw-r--r-- | pkg/commands/git.go | 2 | ||||
-rw-r--r-- | pkg/commands/git_test.go | 5 | ||||
-rw-r--r-- | pkg/config/app_config.go | 18 | ||||
-rw-r--r-- | pkg/gui/dummies.go | 3 | ||||
-rw-r--r-- | pkg/gui/gui.go | 7 | ||||
-rw-r--r-- | pkg/gui/recent_repos_panel.go | 2 | ||||
-rw-r--r-- | pkg/updates/updates.go | 15 | ||||
-rw-r--r-- | pkg/utils/dummies.go | 3 |
9 files changed, 26 insertions, 40 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go index 9fae9e2d0..747f5205f 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -96,13 +96,15 @@ func newLogger(config config.AppConfigurer) *logrus.Entry { // NewApp bootstrap a new application func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { + userConfig := config.GetUserConfig() + app := &App{ closers: []io.Closer{}, Config: config, } var err error log := newLogger(config) - tr, err := i18n.NewTranslationSetFromConfig(log, config.GetUserConfig().Gui.Language) + tr, err := i18n.NewTranslationSetFromConfig(log, userConfig.Gui.Language) if err != nil { return app, err } @@ -110,7 +112,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { app.Common = &common.Common{ Log: log, Tr: tr, - UserConfig: config.GetUserConfig(), + UserConfig: userConfig, Debug: config.GetDebug(), } @@ -122,7 +124,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { app.OSCommand = oscommands.NewOSCommand(app.Common) - app.Updater, err = updates.NewUpdater(log, config, app.OSCommand, app.Tr) + app.Updater, err = updates.NewUpdater(app.Common, config, app.OSCommand) if err != nil { return app, err } @@ -135,7 +137,6 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) { app.GitCommand, err = commands.NewGitCommand( app.Common, app.OSCommand, - app.Config, git_config.NewStdCachedGitConfig(app.Log), ) if err != nil { @@ -207,7 +208,7 @@ func (app *App) setupRepo() (bool, error) { } shouldInitRepo := true - notARepository := app.Config.GetUserConfig().NotARepository + notARepository := app.UserConfig.NotARepository if notARepository == "prompt" { // Offer to initialize a new repository in current directory. fmt.Print(app.Tr.CreateRepo) diff --git a/pkg/commands/git.go b/pkg/commands/git.go index cdccfc29c..dd3879b82 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -15,7 +15,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/common" - "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/env" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -49,7 +48,6 @@ type GitCommand struct { func NewGitCommand( cmn *common.Common, osCommand *oscommands.OSCommand, - config config.AppConfigurer, gitConfig git_config.IGitConfig, ) (*GitCommand, error) { var repo *gogit.Repository diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go index 19eabd583..b730bf6dc 100644 --- a/pkg/commands/git_test.go +++ b/pkg/commands/git_test.go @@ -10,8 +10,6 @@ import ( gogit "github.com/jesseduffield/go-git/v5" "github.com/jesseduffield/lazygit/pkg/commands/git_config" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" - "github.com/jesseduffield/lazygit/pkg/config" - "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/stretchr/testify/assert" ) @@ -210,8 +208,7 @@ func TestNewGitCommand(t *testing.T) { for _, s := range scenarios { t.Run(s.testName, func(t *testing.T) { s.setup() - newAppConfig := config.NewDummyAppConfig() - s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog(), newAppConfig.GetUserConfig().Gui.Language), newAppConfig, git_config.NewFakeGitConfig(nil))) + s.test(NewGitCommand(utils.NewDummyCommon(), oscommands.NewDummyOSCommand(), git_config.NewFakeGitConfig(nil))) }) } } diff --git a/pkg/config/app_config.go b/pkg/config/app_config.go index 7ce467335..98620ad43 100644 --- a/pkg/config/app_config.go +++ b/pkg/config/app_config.go @@ -31,18 +31,21 @@ type AppConfig struct { // from AppConfig and still be used by lazygit. type AppConfigurer interface { GetDebug() bool + + // build info GetVersion() string GetCommit() string GetBuildDate() string GetName() string GetBuildSource() string + GetUserConfig() *UserConfig GetUserConfigPaths() []string GetUserConfigDir() string + ReloadUserConfig() error + GetAppState() *AppState SaveAppState() error - ReloadUserConfig() error - ShowCommandLogOnStartup() bool } // NewAppConfig makes a new app config @@ -255,17 +258,6 @@ func (c *AppConfig) SaveAppState() error { return err } -// 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 -func (c *AppConfig) ShowCommandLogOnStartup() bool { - if !c.UserConfig.Gui.ShowCommandLog { - return false - } - - return !c.AppState.HideCommandLog -} - // loadAppState loads recorded AppState from file func loadAppState() (*AppState, error) { filepath, err := configFilePath("state.yml") diff --git a/pkg/gui/dummies.go b/pkg/gui/dummies.go index 92a9c4d25..b86c7b8bc 100644 --- a/pkg/gui/dummies.go +++ b/pkg/gui/dummies.go @@ -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 } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 243af8b84..6ee63e34c 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -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) diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 60e1ffaca..64f99c611 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -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 } diff --git a/pkg/updates/updates.go b/pkg/updates/updates.go index b6d0f2734..16397bb9b 100644 --- a/pkg/updates/updates.go +++ b/pkg/updates/updates.go @@ -16,19 +16,17 @@ import ( "github.com/kardianos/osext" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" + "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/constants" - "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/utils" - "github.com/sirupsen/logrus" ) // Updater checks for updates and does updates type Updater struct { - Log *logrus.Entry + *common.Common Config config.AppConfigurer OSCommand *oscommands.OSCommand - Tr *i18n.TranslationSet } // Updaterer implements the check and update methods @@ -38,14 +36,11 @@ type Updaterer interface { } // NewUpdater creates a new updater -func NewUpdater(log *logrus.Entry, config config.AppConfigurer, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet) (*Updater, error) { - contextLogger := log.WithField("context", "updates") - +func NewUpdater(cmn *common.Common, config config.AppConfigurer, osCommand *oscommands.OSCommand) (*Updater, error) { return &Updater{ - Log: contextLogger, + Common: cmn, Config: config, OSCommand: osCommand, - Tr: tr, }, nil } @@ -177,7 +172,7 @@ func (u *Updater) skipUpdateCheck() bool { return true } - userConfig := u.Config.GetUserConfig() + userConfig := u.UserConfig if userConfig.Update.Method == "never" { u.Log.Info("Update method is set to never so we won't check for an update") return true diff --git a/pkg/utils/dummies.go b/pkg/utils/dummies.go index b05f444b4..a9dfcd88a 100644 --- a/pkg/utils/dummies.go +++ b/pkg/utils/dummies.go @@ -18,10 +18,9 @@ func NewDummyLog() *logrus.Entry { func NewDummyCommon() *common.Common { tr := i18n.EnglishTranslationSet() - newAppConfig := config.NewDummyAppConfig() return &common.Common{ Log: NewDummyLog(), Tr: &tr, - UserConfig: newAppConfig.GetUserConfig(), + UserConfig: config.GetDefaultConfig(), } } |