summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-12-30 17:36:21 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-12-30 17:36:21 +1100
commit07afb5359e64aaf9074c5a67ba595aeb4a75a1a3 (patch)
treee7b6c9c780b4538691efb247168d02a042fabbba /pkg
parent3f1cda88ed87bb7cb2c9cdd63f02754347961e41 (diff)
move remotes loader into loaders package
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/loaders/reflog_commits.go (renamed from pkg/commands/loaders/loading_reflog_commits.go)0
-rw-r--r--pkg/commands/loaders/remotes.go (renamed from pkg/commands/loading_remotes.go)29
-rw-r--r--pkg/gui/remotes_panel.go3
3 files changed, 27 insertions, 5 deletions
diff --git a/pkg/commands/loaders/loading_reflog_commits.go b/pkg/commands/loaders/reflog_commits.go
index 012c7c297..012c7c297 100644
--- a/pkg/commands/loaders/loading_reflog_commits.go
+++ b/pkg/commands/loaders/reflog_commits.go
diff --git a/pkg/commands/loading_remotes.go b/pkg/commands/loaders/remotes.go
index 0a581fff5..c0734ab32 100644
--- a/pkg/commands/loading_remotes.go
+++ b/pkg/commands/loaders/remotes.go
@@ -1,4 +1,4 @@
-package commands
+package loaders
import (
"fmt"
@@ -6,16 +6,37 @@ import (
"sort"
"strings"
+ gogit "github.com/jesseduffield/go-git/v5"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+ "github.com/jesseduffield/lazygit/pkg/common"
)
-func (c *GitCommand) GetRemotes() ([]*models.Remote, error) {
- remoteBranchesStr, err := c.Cmd.New("git branch -r").RunWithOutput()
+type RemoteLoader struct {
+ *common.Common
+ cmd oscommands.ICmdObjBuilder
+ getGoGitRemotes func() ([]*gogit.Remote, error)
+}
+
+func NewRemoteLoader(
+ common *common.Common,
+ cmd oscommands.ICmdObjBuilder,
+ getGoGitRemotes func() ([]*gogit.Remote, error),
+) *RemoteLoader {
+ return &RemoteLoader{
+ Common: common,
+ cmd: cmd,
+ getGoGitRemotes: getGoGitRemotes,
+ }
+}
+
+func (self *RemoteLoader) GetRemotes() ([]*models.Remote, error) {
+ remoteBranchesStr, err := self.cmd.New("git branch -r").RunWithOutput()
if err != nil {
return nil, err
}
- goGitRemotes, err := c.Repo.Remotes()
+ goGitRemotes, err := self.getGoGitRemotes()
if err != nil {
return nil, err
}
diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go
index 1731aacba..999ec1a10 100644
--- a/pkg/gui/remotes_panel.go
+++ b/pkg/gui/remotes_panel.go
@@ -4,6 +4,7 @@ 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"
@@ -40,7 +41,7 @@ func (gui *Gui) remotesRenderToMain() error {
func (gui *Gui) refreshRemotes() error {
prevSelectedRemote := gui.getSelectedRemote()
- remotes, err := gui.GitCommand.GetRemotes()
+ remotes, err := loaders.NewRemoteLoader(gui.Common, gui.GitCommand.Cmd, gui.GitCommand.Repo.Remotes).GetRemotes()
if err != nil {
return gui.surfaceError(err)
}