1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

resetting controllers on new repo

This commit is contained in:
Jesse Duffield
2022-01-31 22:11:34 +11:00
parent eb056576cf
commit 2a1e3faa0c
76 changed files with 514 additions and 370 deletions

View File

@ -5,7 +5,6 @@ import (
"path/filepath"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/git_config"
"github.com/jesseduffield/lazygit/pkg/env"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
@ -71,16 +70,9 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
return err
}
newGitCommand, err := commands.NewGitCommand(
gui.Common,
gui.OSCommand,
git_config.NewStdCachedGitConfig(gui.Log),
gui.Mutexes.SyncMutex,
)
if err != nil {
if err := gui.recordCurrentDirectory(); err != nil {
return err
}
gui.git = newGitCommand
// these two mutexes are used by our background goroutines (triggered via `gui.goEvery`. We don't want to
// switch to a repo while one of these goroutines is in the process of updating something
@ -90,13 +82,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
gui.Mutexes.RefreshingFilesMutex.Lock()
defer gui.Mutexes.RefreshingFilesMutex.Unlock()
if err := gui.recordCurrentDirectory(); err != nil {
return err
}
gui.resetState("", reuse)
return nil
return gui.onNewRepo("", reuse)
}
// updateRecentRepoList registers the fact that we opened lazygit in this repo,