diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-30 17:36:21 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-04 09:07:15 +1100 |
commit | 44b6d26b100a98d999127e6b418fdff25fcebc1c (patch) | |
tree | d5f1fd2638827ad093613b3cdc18e2b54dd1f47d /pkg/commands | |
parent | d69ce7a529474565ea61f1e104d3e42cd55ff8e1 (diff) |
move remotes loader into loaders package
Diffstat (limited to 'pkg/commands')
-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 |
2 files changed, 25 insertions, 4 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 } |