summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/sync_controller.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-06 15:54:26 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit722410aded4e3d14356c7ab94bfa15abe10359fa (patch)
tree8e8a57503b0b57bccca5fa8cd146bc699960033f /pkg/gui/controllers/sync_controller.go
parentb93b8cc00a2f2ea339b1ecdbc380320556490d3b (diff)
refactor controllers
Diffstat (limited to 'pkg/gui/controllers/sync_controller.go')
-rw-r--r--pkg/gui/controllers/sync_controller.go34
1 files changed, 10 insertions, 24 deletions
diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go
index f3f2894b0..74db3d527 100644
--- a/pkg/gui/controllers/sync_controller.go
+++ b/pkg/gui/controllers/sync_controller.go
@@ -4,7 +4,6 @@ import (
"fmt"
"strings"
- "github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/git_commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/types"
@@ -12,35 +11,22 @@ import (
type SyncController struct {
baseController
+ *controllerCommon
- c *types.ControllerCommon
- git *commands.GitCommand
-
- getCheckedOutBranch func() *models.Branch
- suggestionsHelper ISuggestionsHelper
- getSuggestedRemote func() string
- CheckMergeOrRebase func(error) error
+ getSuggestedRemote func() string
}
var _ types.IController = &SyncController{}
func NewSyncController(
- c *types.ControllerCommon,
- git *commands.GitCommand,
- getCheckedOutBranch func() *models.Branch,
- suggestionsHelper ISuggestionsHelper,
+ common *controllerCommon,
getSuggestedRemote func() string,
- CheckMergeOrRebase func(error) error,
) *SyncController {
return &SyncController{
- baseController: baseController{},
- c: c,
- git: git,
-
- getCheckedOutBranch: getCheckedOutBranch,
- suggestionsHelper: suggestionsHelper,
- getSuggestedRemote: getSuggestedRemote,
- CheckMergeOrRebase: CheckMergeOrRebase,
+ baseController: baseController{},
+ controllerCommon: common,
+
+ getSuggestedRemote: getSuggestedRemote,
}
}
@@ -75,7 +61,7 @@ func (self *SyncController) HandlePull() error {
func (self *SyncController) branchCheckedOut(f func(*models.Branch) error) func() error {
return func() error {
- currentBranch := self.getCheckedOutBranch()
+ currentBranch := self.helpers.Refs.GetCheckedOutRef()
if currentBranch == nil {
// need to wait for branches to refresh
return nil
@@ -160,7 +146,7 @@ func (self *SyncController) promptForUpstream(currentBranch *models.Branch, onCo
return self.c.Prompt(types.PromptOpts{
Title: self.c.Tr.EnterUpstream,
InitialContent: suggestedRemote + " " + currentBranch.Name,
- FindSuggestionsFunc: self.suggestionsHelper.GetRemoteBranchesSuggestionsFunc(" "),
+ FindSuggestionsFunc: self.helpers.Suggestions.GetRemoteBranchesSuggestionsFunc(" "),
HandleConfirm: onConfirm,
})
}
@@ -189,7 +175,7 @@ func (self *SyncController) pullWithLock(opts PullFilesOptions) error {
},
)
- return self.CheckMergeOrRebase(err)
+ return self.helpers.MergeAndRebase.CheckMergeOrRebase(err)
}
type pushOpts struct {