mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 21:05:48 +02:00
move remotes loader into loaders package
This commit is contained in:
parent
d69ce7a529
commit
44b6d26b10
3 changed files with 27 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
package commands
|
package loaders
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -6,16 +6,37 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
gogit "github.com/jesseduffield/go-git/v5"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"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) {
|
type RemoteLoader struct {
|
||||||
remoteBranchesStr, err := c.Cmd.New("git branch -r").RunWithOutput()
|
*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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
goGitRemotes, err := c.Repo.Remotes()
|
goGitRemotes, err := self.getGoGitRemotes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
|
@ -40,7 +41,7 @@ func (gui *Gui) remotesRenderToMain() error {
|
||||||
func (gui *Gui) refreshRemotes() error {
|
func (gui *Gui) refreshRemotes() error {
|
||||||
prevSelectedRemote := gui.getSelectedRemote()
|
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 {
|
if err != nil {
|
||||||
return gui.surfaceError(err)
|
return gui.surfaceError(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue