mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-11-21 04:46:29 +03:00
Remove the unused AppState field from Common
Nothing reads it. It's a pointer to the AppConfig's in-memory copy of state.yml, which the following commits replace with fresh reads of the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5a6d5de3b8
commit
90039cf7e2
10 files changed
+16
-21
No files matched your search
+4
-6
@@ -63,17 +63,15 @@ func Run(
|
||||
|
||||
func NewCommon(config config.AppConfigurer, log *logrus.Entry) (*common.Common, error) {
|
||||
userConfig := config.GetUserConfig()
|
||||
appState := config.GetAppState()
|
||||
// Initialize with English for the time being; the real translation set for
|
||||
// the configured language will be read after reading the user config
|
||||
tr := i18n.EnglishTranslationSet()
|
||||
|
||||
cmn := &common.Common{
|
||||
Log: log,
|
||||
Tr: tr,
|
||||
AppState: appState,
|
||||
Debug: config.GetDebug(),
|
||||
Fs: afero.NewOsFs(),
|
||||
Log: log,
|
||||
Tr: tr,
|
||||
Debug: config.GetDebug(),
|
||||
Fs: afero.NewOsFs(),
|
||||
}
|
||||
cmn.SetUserConfig(userConfig)
|
||||
return cmn, nil
|
||||
|
||||
@@ -339,7 +339,7 @@ func TestCommitShowCmdObj(t *testing.T) {
|
||||
repoPaths := RepoPaths{
|
||||
worktreePath: "/path/to/worktree",
|
||||
}
|
||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig, appState: &config.AppState{}, runner: runner, repoPaths: &repoPaths})
|
||||
instance := buildCommitCommands(commonDeps{userConfig: userConfig, runner: runner, repoPaths: &repoPaths})
|
||||
|
||||
assert.NoError(t, instance.ShowCmdObj("1234567890", s.filterPaths, DiffModeRendered).Run())
|
||||
runner.CheckForMissingCalls()
|
||||
|
||||
@@ -14,7 +14,6 @@ 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 +31,7 @@ func buildGitCommon(deps commonDeps) *GitCommon {
|
||||
|
||||
gitCommon.Common = deps.common
|
||||
if gitCommon.Common == nil {
|
||||
gitCommon.Common = common.NewDummyCommonWithUserConfigAndAppState(deps.userConfig, deps.appState)
|
||||
gitCommon.Common = common.NewDummyCommonWithUserConfig(deps.userConfig)
|
||||
}
|
||||
|
||||
if deps.fs != nil {
|
||||
|
||||
@@ -319,7 +319,7 @@ func TestFileGetStatusFiles(t *testing.T) {
|
||||
userConfig.Git.RenameSimilarityThreshold = s.similarityThreshold
|
||||
|
||||
loader := &FileLoader{
|
||||
GitCommon: buildGitCommon(commonDeps{appState: &config.AppState{}, userConfig: userConfig}),
|
||||
GitCommon: buildGitCommon(commonDeps{userConfig: userConfig}),
|
||||
cmd: cmd,
|
||||
config: &FakeFileLoaderConfig{showUntrackedFiles: "yes"},
|
||||
getFileType: func(string) string { return "file" },
|
||||
|
||||
@@ -172,7 +172,7 @@ func TestStashStashEntryCmdObj(t *testing.T) {
|
||||
repoPaths := RepoPaths{
|
||||
worktreePath: "/path/to/worktree",
|
||||
}
|
||||
instance := buildStashCommands(commonDeps{userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||
instance := buildStashCommands(commonDeps{userConfig: userConfig, repoPaths: &repoPaths})
|
||||
|
||||
cmdStr := instance.ShowStashEntryCmdObj(s.index, DiffModeRendered).Args()
|
||||
assert.Equal(t, s.expected, cmdStr)
|
||||
|
||||
@@ -325,7 +325,7 @@ func TestWorkingTreeDiff(t *testing.T) {
|
||||
worktreePath: "/path/to/worktree",
|
||||
}
|
||||
|
||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, repoPaths: &repoPaths})
|
||||
result := instance.WorktreeFileDiff(s.file, s.mode, s.cached)
|
||||
assert.Equal(t, expectedResult, result)
|
||||
s.runner.CheckForMissingCalls()
|
||||
@@ -410,7 +410,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
|
||||
worktreePath: "/path/to/worktree",
|
||||
}
|
||||
|
||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, appState: &config.AppState{}, repoPaths: &repoPaths})
|
||||
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, userConfig: userConfig, repoPaths: &repoPaths})
|
||||
|
||||
result, err := instance.ShowFileDiff(s.from, s.to, s.reverse, s.fileName, s.previousPath, s.mode)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@@ -14,7 +14,6 @@ type Common struct {
|
||||
Log *logrus.Entry
|
||||
Tr *i18n.TranslationSet
|
||||
userConfig atomic.Pointer[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
|
||||
|
||||
@@ -18,12 +18,11 @@ func NewDummyCommon() *Common {
|
||||
return cmn
|
||||
}
|
||||
|
||||
func NewDummyCommonWithUserConfigAndAppState(userConfig *config.UserConfig, appState *config.AppState) *Common {
|
||||
func NewDummyCommonWithUserConfig(userConfig *config.UserConfig) *Common {
|
||||
tr := i18n.EnglishTranslationSet()
|
||||
cmn := &Common{
|
||||
Log: utils.NewDummyLog(),
|
||||
Tr: tr,
|
||||
AppState: appState,
|
||||
Log: utils.NewDummyLog(),
|
||||
Tr: tr,
|
||||
// TODO: remove dependency on actual filesystem in tests and switch to using
|
||||
// in-memory for everything
|
||||
Fs: afero.NewOsFs(),
|
||||
|
||||
@@ -169,7 +169,7 @@ func TestFileTreeSortOrderConfig(t *testing.T) {
|
||||
userConfig.Gui.ShowRootItemInFileTree = false
|
||||
userConfig.Gui.FileTreeSortOrder = s.sortOrder
|
||||
userConfig.Gui.FileTreeSortCaseSensitive = s.caseSensitive
|
||||
cmn := common.NewDummyCommonWithUserConfigAndAppState(userConfig, nil)
|
||||
cmn := common.NewDummyCommonWithUserConfig(userConfig)
|
||||
tree := NewFileTree(func() []*models.File { return files }, cmn, true)
|
||||
tree.SetTree()
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ func TestSetTreeSelectsNewFileWhenSelectedRenameSplits(t *testing.T) {
|
||||
t.Run(s.name, func(t *testing.T) {
|
||||
userConfig := config.GetDefaultConfig()
|
||||
userConfig.Gui.ShowRootItemInFileTree = s.showRootItem
|
||||
cmn := common.NewDummyCommonWithUserConfigAndAppState(userConfig, nil)
|
||||
cmn := common.NewDummyCommonWithUserConfig(userConfig)
|
||||
|
||||
files := []*models.File{
|
||||
{Path: "dir/new.go", PreviousPath: "dir/old.go"},
|
||||
@@ -102,7 +102,7 @@ func TestSetTreeFollowsRenameIntoCollapsedDir(t *testing.T) {
|
||||
t.Run(s.name, func(t *testing.T) {
|
||||
userConfig := config.GetDefaultConfig()
|
||||
userConfig.Gui.ShowRootItemInFileTree = s.showRootItem
|
||||
cmn := common.NewDummyCommonWithUserConfigAndAppState(userConfig, nil)
|
||||
cmn := common.NewDummyCommonWithUserConfig(userConfig)
|
||||
|
||||
files := []*models.File{
|
||||
{Path: "a/b.go"},
|
||||
|
||||
Reference in new issue
Block a user