mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-29 22:48:24 +02:00
split context common from helper common
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type controllerCommon struct {
|
||||
c *types.HelperCommon
|
||||
c *helpers.HelperCommon
|
||||
helpers *helpers.Helpers
|
||||
contexts *context.ContextTree
|
||||
|
||||
@@ -26,7 +26,7 @@ type controllerCommon struct {
|
||||
}
|
||||
|
||||
func NewControllerCommon(
|
||||
c *types.HelperCommon,
|
||||
c *helpers.HelperCommon,
|
||||
os *oscommands.OSCommand,
|
||||
git *commands.GitCommand,
|
||||
helpers *helpers.Helpers,
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type BisectHelper struct {
|
||||
c *types.HelperCommon
|
||||
git *commands.GitCommand
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
func NewBisectHelper(
|
||||
c *types.HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
) *BisectHelper {
|
||||
return &BisectHelper{
|
||||
c: c,
|
||||
git: git,
|
||||
}
|
||||
func NewBisectHelper(c *HelperCommon) *BisectHelper {
|
||||
return &BisectHelper{c: c}
|
||||
}
|
||||
|
||||
func (self *BisectHelper) Reset() error {
|
||||
@@ -26,7 +18,7 @@ func (self *BisectHelper) Reset() error {
|
||||
Prompt: self.c.Tr.Bisect.ResetPrompt,
|
||||
HandleConfirm: func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.ResetBisect)
|
||||
if err := self.git.Bisect.Reset(); err != nil {
|
||||
if err := self.c.Git().Bisect.Reset(); err != nil {
|
||||
return self.c.Error(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
|
||||
@@ -9,9 +8,7 @@ import (
|
||||
)
|
||||
|
||||
type CherryPickHelper struct {
|
||||
c *types.HelperCommon
|
||||
|
||||
git *commands.GitCommand
|
||||
c *HelperCommon
|
||||
|
||||
contexts *context.ContextTree
|
||||
|
||||
@@ -22,14 +19,12 @@ type CherryPickHelper struct {
|
||||
// even if in truth we're running git cherry-pick
|
||||
|
||||
func NewCherryPickHelper(
|
||||
c *types.HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
c *HelperCommon,
|
||||
contexts *context.ContextTree,
|
||||
rebaseHelper *MergeAndRebaseHelper,
|
||||
) *CherryPickHelper {
|
||||
return &CherryPickHelper{
|
||||
c: c,
|
||||
git: git,
|
||||
contexts: contexts,
|
||||
rebaseHelper: rebaseHelper,
|
||||
}
|
||||
@@ -87,7 +82,7 @@ func (self *CherryPickHelper) Paste() error {
|
||||
HandleConfirm: func() error {
|
||||
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func() error {
|
||||
self.c.LogAction(self.c.Tr.Actions.CherryPick)
|
||||
err := self.git.Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
||||
err := self.c.Git().Rebase.CherryPickCommits(self.getData().CherryPickedCommits)
|
||||
return self.rebaseHelper.CheckMergeOrRebase(err)
|
||||
})
|
||||
},
|
||||
|
||||
@@ -15,12 +15,12 @@ import (
|
||||
)
|
||||
|
||||
type ConfirmationHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
contexts *context.ContextTree
|
||||
}
|
||||
|
||||
func NewConfirmationHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
contexts *context.ContextTree,
|
||||
) *ConfirmationHelper {
|
||||
return &ConfirmationHelper{
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
type CredentialsHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
func NewCredentialsHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
) *CredentialsHelper {
|
||||
return &CredentialsHelper{
|
||||
c: c,
|
||||
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
)
|
||||
|
||||
type DiffHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
func NewDiffHelper(c *types.HelperCommon) *DiffHelper {
|
||||
func NewDiffHelper(c *HelperCommon) *DiffHelper {
|
||||
return &DiffHelper{
|
||||
c: c,
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package helpers
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type IFilesHelper interface {
|
||||
@@ -13,13 +12,13 @@ type IFilesHelper interface {
|
||||
}
|
||||
|
||||
type FilesHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
os *oscommands.OSCommand
|
||||
}
|
||||
|
||||
func NewFilesHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
os *oscommands.OSCommand,
|
||||
) *FilesHelper {
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type GpgHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
os *oscommands.OSCommand
|
||||
git *commands.GitCommand
|
||||
}
|
||||
|
||||
func NewGpgHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
os *oscommands.OSCommand,
|
||||
git *commands.GitCommand,
|
||||
) *GpgHelper {
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type HelperCommon struct {
|
||||
*common.Common
|
||||
types.IGuiCommon
|
||||
IGetContexts
|
||||
}
|
||||
|
||||
type IGetContexts interface {
|
||||
Contexts() *context.ContextTree
|
||||
}
|
||||
|
||||
type Helpers struct {
|
||||
Refs *RefsHelper
|
||||
Bisect *BisectHelper
|
||||
|
||||
@@ -3,7 +3,6 @@ package helpers
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/hosting_service"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
// this helper just wraps our hosting_service package
|
||||
@@ -14,12 +13,12 @@ type IHostHelper interface {
|
||||
}
|
||||
|
||||
type HostHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
}
|
||||
|
||||
func NewHostHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
) *HostHelper {
|
||||
return &HostHelper{
|
||||
|
||||
@@ -14,14 +14,14 @@ import (
|
||||
)
|
||||
|
||||
type MergeAndRebaseHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
contexts *context.ContextTree
|
||||
git *commands.GitCommand
|
||||
refsHelper *RefsHelper
|
||||
}
|
||||
|
||||
func NewMergeAndRebaseHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
contexts *context.ContextTree,
|
||||
git *commands.GitCommand,
|
||||
refsHelper *RefsHelper,
|
||||
|
||||
@@ -7,13 +7,13 @@ import (
|
||||
)
|
||||
|
||||
type MergeConflictsHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
contexts *context.ContextTree
|
||||
git *commands.GitCommand
|
||||
}
|
||||
|
||||
func NewMergeConflictsHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
contexts *context.ContextTree,
|
||||
git *commands.GitCommand,
|
||||
) *MergeConflictsHelper {
|
||||
|
||||
@@ -13,13 +13,13 @@ type IPatchBuildingHelper interface {
|
||||
}
|
||||
|
||||
type PatchBuildingHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
contexts *context.ContextTree
|
||||
}
|
||||
|
||||
func NewPatchBuildingHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
contexts *context.ContextTree,
|
||||
) *PatchBuildingHelper {
|
||||
|
||||
@@ -2,15 +2,13 @@ package helpers
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type RecordDirectoryHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
}
|
||||
|
||||
func NewRecordDirectoryHelper(c *types.HelperCommon) *RecordDirectoryHelper {
|
||||
func NewRecordDirectoryHelper(c *HelperCommon) *RecordDirectoryHelper {
|
||||
return &RecordDirectoryHelper{
|
||||
c: c,
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
)
|
||||
|
||||
type RefreshHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
contexts *context.ContextTree
|
||||
git *commands.GitCommand
|
||||
refsHelper *RefsHelper
|
||||
@@ -33,7 +33,7 @@ type RefreshHelper struct {
|
||||
}
|
||||
|
||||
func NewRefreshHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
contexts *context.ContextTree,
|
||||
git *commands.GitCommand,
|
||||
refsHelper *RefsHelper,
|
||||
|
||||
@@ -23,14 +23,14 @@ type IRefsHelper interface {
|
||||
}
|
||||
|
||||
type RefsHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
contexts *context.ContextTree
|
||||
model *types.Model
|
||||
}
|
||||
|
||||
func NewRefsHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
contexts *context.ContextTree,
|
||||
model *types.Model,
|
||||
|
||||
@@ -22,13 +22,13 @@ type onNewRepoFn func(startArgs appTypes.StartArgs, reuseState bool) error
|
||||
|
||||
// helps switch back and forth between repos
|
||||
type ReposHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
recordDirectoryHelper *RecordDirectoryHelper
|
||||
onNewRepo onNewRepoFn
|
||||
}
|
||||
|
||||
func NewRecentReposHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
recordDirectoryHelper *RecordDirectoryHelper,
|
||||
onNewRepo onNewRepoFn,
|
||||
) *ReposHelper {
|
||||
|
||||
@@ -5,16 +5,15 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/snake"
|
||||
)
|
||||
|
||||
type SnakeHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
game *snake.Game
|
||||
}
|
||||
|
||||
func NewSnakeHelper(c *types.HelperCommon) *SnakeHelper {
|
||||
func NewSnakeHelper(c *HelperCommon) *SnakeHelper {
|
||||
return &SnakeHelper{
|
||||
c: c,
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
)
|
||||
|
||||
type StagingHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
contexts *context.ContextTree
|
||||
}
|
||||
|
||||
func NewStagingHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
contexts *context.ContextTree,
|
||||
) *StagingHelper {
|
||||
|
||||
@@ -34,7 +34,7 @@ type ISuggestionsHelper interface {
|
||||
}
|
||||
|
||||
type SuggestionsHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
|
||||
model *types.Model
|
||||
contexts *context.ContextTree
|
||||
@@ -43,7 +43,7 @@ type SuggestionsHelper struct {
|
||||
var _ ISuggestionsHelper = &SuggestionsHelper{}
|
||||
|
||||
func NewSuggestionsHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
model *types.Model,
|
||||
contexts *context.ContextTree,
|
||||
) *SuggestionsHelper {
|
||||
|
||||
@@ -10,11 +10,11 @@ import (
|
||||
// and the commits context.
|
||||
|
||||
type TagsHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
}
|
||||
|
||||
func NewTagsHelper(c *types.HelperCommon, git *commands.GitCommand) *TagsHelper {
|
||||
func NewTagsHelper(c *HelperCommon, git *commands.GitCommand) *TagsHelper {
|
||||
return &TagsHelper{
|
||||
c: c,
|
||||
git: git,
|
||||
|
||||
@@ -7,11 +7,11 @@ import (
|
||||
)
|
||||
|
||||
type UpdateHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
updater *updates.Updater
|
||||
}
|
||||
|
||||
func NewUpdateHelper(c *types.HelperCommon, updater *updates.Updater) *UpdateHelper {
|
||||
func NewUpdateHelper(c *HelperCommon, updater *updates.Updater) *UpdateHelper {
|
||||
return &UpdateHelper{
|
||||
c: c,
|
||||
updater: updater,
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type UpstreamHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
model *types.Model
|
||||
|
||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion
|
||||
@@ -25,7 +25,7 @@ type IUpstreamHelper interface {
|
||||
var _ IUpstreamHelper = &UpstreamHelper{}
|
||||
|
||||
func NewUpstreamHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
model *types.Model,
|
||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion,
|
||||
) *UpstreamHelper {
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
type ViewHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
contexts *context.ContextTree
|
||||
}
|
||||
|
||||
func NewViewHelper(c *types.HelperCommon, contexts *context.ContextTree) *ViewHelper {
|
||||
func NewViewHelper(c *HelperCommon, contexts *context.ContextTree) *ViewHelper {
|
||||
return &ViewHelper{
|
||||
c: c,
|
||||
contexts: contexts,
|
||||
|
||||
@@ -11,12 +11,12 @@ import (
|
||||
)
|
||||
|
||||
type WindowHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
viewHelper *ViewHelper
|
||||
contexts *context.ContextTree
|
||||
}
|
||||
|
||||
func NewWindowHelper(c *types.HelperCommon, viewHelper *ViewHelper, contexts *context.ContextTree) *WindowHelper {
|
||||
func NewWindowHelper(c *HelperCommon, viewHelper *ViewHelper, contexts *context.ContextTree) *WindowHelper {
|
||||
return &WindowHelper{
|
||||
c: c,
|
||||
viewHelper: viewHelper,
|
||||
|
||||
@@ -20,7 +20,7 @@ type IWorkingTreeHelper interface {
|
||||
}
|
||||
|
||||
type WorkingTreeHelper struct {
|
||||
c *types.HelperCommon
|
||||
c *HelperCommon
|
||||
git *commands.GitCommand
|
||||
contexts *context.ContextTree
|
||||
refHelper *RefsHelper
|
||||
@@ -30,7 +30,7 @@ type WorkingTreeHelper struct {
|
||||
}
|
||||
|
||||
func NewWorkingTreeHelper(
|
||||
c *types.HelperCommon,
|
||||
c *HelperCommon,
|
||||
git *commands.GitCommand,
|
||||
contexts *context.ContextTree,
|
||||
refHelper *RefsHelper,
|
||||
|
||||
@@ -6,26 +6,26 @@ import (
|
||||
)
|
||||
|
||||
type ListControllerFactory struct {
|
||||
c *types.HelperCommon
|
||||
*controllerCommon
|
||||
}
|
||||
|
||||
func NewListControllerFactory(c *types.HelperCommon) *ListControllerFactory {
|
||||
func NewListControllerFactory(c *controllerCommon) *ListControllerFactory {
|
||||
return &ListControllerFactory{
|
||||
c: c,
|
||||
controllerCommon: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ListControllerFactory) Create(context types.IListContext) *ListController {
|
||||
return &ListController{
|
||||
baseController: baseController{},
|
||||
c: self.c,
|
||||
context: context,
|
||||
baseController: baseController{},
|
||||
controllerCommon: self.controllerCommon,
|
||||
context: context,
|
||||
}
|
||||
}
|
||||
|
||||
type ListController struct {
|
||||
baseController
|
||||
c *types.HelperCommon
|
||||
*controllerCommon
|
||||
|
||||
context types.IListContext
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
"github.com/samber/lo"
|
||||
@@ -184,7 +185,7 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error {
|
||||
}
|
||||
}
|
||||
|
||||
func secondaryPatchPanelUpdateOpts(c *types.HelperCommon) *types.ViewUpdateOpts {
|
||||
func secondaryPatchPanelUpdateOpts(c *helpers.HelperCommon) *types.ViewUpdateOpts {
|
||||
if c.Git().Patch.PatchBuilder.Active() {
|
||||
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user