diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-02 10:21:32 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | 194ff1630c11303e3de1c87f61103b3aadcd175d (patch) | |
tree | ab57dbd60347668e12c72d6e169063e770c3beac /pkg/gui | |
parent | 2cb8aff940b79f20a09c0ed2bde13ec3b34a13cb (diff) |
do dependency injection up front and in one place
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/branches_panel.go | 10 | ||||
-rw-r--r-- | pkg/gui/commit_files_panel.go | 3 | ||||
-rw-r--r-- | pkg/gui/commits_panel.go | 8 | ||||
-rw-r--r-- | pkg/gui/remotes_panel.go | 3 | ||||
-rw-r--r-- | pkg/gui/sub_commits_panel.go | 4 | ||||
-rw-r--r-- | pkg/gui/tags_panel.go | 3 |
6 files changed, 8 insertions, 23 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 14e9e9743..62062043e 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/jesseduffield/lazygit/pkg/commands" - "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" "github.com/jesseduffield/lazygit/pkg/utils" @@ -56,18 +55,13 @@ func (gui *Gui) refreshBranches() { // which allows us to order them correctly. So if we're filtering we'll just // manually load all the reflog commits here var err error - reflogCommits, _, err = loaders.NewReflogCommitLoader(gui.Common, gui.GitCommand.Cmd).GetReflogCommits(nil, "") + reflogCommits, _, err = gui.GitCommand.Loaders.ReflogCommits.GetReflogCommits(nil, "") if err != nil { gui.Log.Error(err) } } - loader := loaders.NewBranchLoader( - gui.Common, - gui.GitCommand, - reflogCommits, - ) - gui.State.Branches = loader.Load() + gui.State.Branches = gui.GitCommand.Loaders.Branches.Load(reflogCommits) if err := gui.postRefreshUpdate(gui.State.Contexts.Branches); err != nil { gui.Log.Error(err) diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 8c300fb4d..3194c436b 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -1,7 +1,6 @@ package gui import ( - "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/patch" "github.com/jesseduffield/lazygit/pkg/gui/filetree" @@ -106,7 +105,7 @@ func (gui *Gui) refreshCommitFilesView() error { to := gui.State.Panels.CommitFiles.refName from, reverse := gui.getFromAndReverseArgsForDiff(to) - files, err := loaders.NewCommitFileLoader(gui.Common, gui.GitCommand.Cmd).GetFilesInDiff(from, to, reverse) + files, err := gui.GitCommand.Loaders.CommitFiles.GetFilesInDiff(from, to, reverse) if err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index ed1718c18..021c1557b 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -119,9 +119,7 @@ func (gui *Gui) refreshCommitsWithLimit() error { gui.Mutexes.BranchCommitsMutex.Lock() defer gui.Mutexes.BranchCommitsMutex.Unlock() - loader := loaders.NewCommitLoader(gui.Common, gui.GitCommand) - - commits, err := loader.GetCommits( + commits, err := gui.GitCommand.Loaders.Commits.GetCommits( loaders.GetCommitsOptions{ Limit: gui.State.Panels.Commits.LimitCommits, FilterPath: gui.State.Modes.Filtering.GetPath(), @@ -142,9 +140,7 @@ func (gui *Gui) refreshRebaseCommits() error { gui.Mutexes.BranchCommitsMutex.Lock() defer gui.Mutexes.BranchCommitsMutex.Unlock() - loader := loaders.NewCommitLoader(gui.Common, gui.GitCommand) - - updatedCommits, err := loader.MergeRebasingCommits(gui.State.Commits) + updatedCommits, err := gui.GitCommand.Loaders.Commits.MergeRebasingCommits(gui.State.Commits) if err != nil { return err } diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 999ec1a10..0a654f365 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/utils" @@ -41,7 +40,7 @@ func (gui *Gui) remotesRenderToMain() error { func (gui *Gui) refreshRemotes() error { prevSelectedRemote := gui.getSelectedRemote() - remotes, err := loaders.NewRemoteLoader(gui.Common, gui.GitCommand.Cmd, gui.GitCommand.Repo.Remotes).GetRemotes() + remotes, err := gui.GitCommand.Loaders.Remotes.GetRemotes() if err != nil { return gui.surfaceError(err) } diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go index 83661100d..aede87f27 100644 --- a/pkg/gui/sub_commits_panel.go +++ b/pkg/gui/sub_commits_panel.go @@ -75,9 +75,7 @@ func (gui *Gui) handleViewSubCommitFiles() error { func (gui *Gui) switchToSubCommitsContext(refName string) error { // need to populate my sub commits - loader := loaders.NewCommitLoader(gui.Common, gui.GitCommand) - - commits, err := loader.GetCommits( + commits, err := gui.GitCommand.Loaders.Commits.GetCommits( loaders.GetCommitsOptions{ Limit: gui.State.Panels.Commits.LimitCommits, FilterPath: gui.State.Modes.Filtering.GetPath(), diff --git a/pkg/gui/tags_panel.go b/pkg/gui/tags_panel.go index 3fc028e6d..9516741e0 100644 --- a/pkg/gui/tags_panel.go +++ b/pkg/gui/tags_panel.go @@ -1,7 +1,6 @@ package gui import ( - "github.com/jesseduffield/lazygit/pkg/commands/loaders" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/utils" ) @@ -40,7 +39,7 @@ func (gui *Gui) tagsRenderToMain() error { // this is a controller: it can't access tags directly. Or can it? It should be able to get but not set. But that's exactly what I'm doing here, setting it. but through a mutator which encapsulates the event. func (gui *Gui) refreshTags() error { - tags, err := loaders.NewTagLoader(gui.Common, gui.GitCommand.Cmd).GetTags() + tags, err := gui.GitCommand.Loaders.Tags.GetTags() if err != nil { return gui.surfaceError(err) } |