mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-02 09:21:40 +02:00
split context common from helper common
This commit is contained in:
parent
f081358943
commit
43251e7275
@ -16,7 +16,7 @@ var (
|
||||
_ types.DiffableContext = (*BranchesContext)(nil)
|
||||
)
|
||||
|
||||
func NewBranchesContext(c *types.HelperCommon) *BranchesContext {
|
||||
func NewBranchesContext(c *ContextCommon) *BranchesContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.Branch { return c.Model().Branches })
|
||||
|
||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||
|
@ -20,7 +20,7 @@ var (
|
||||
_ types.DiffableContext = (*CommitFilesContext)(nil)
|
||||
)
|
||||
|
||||
func NewCommitFilesContext(c *types.HelperCommon) *CommitFilesContext {
|
||||
func NewCommitFilesContext(c *ContextCommon) *CommitFilesContext {
|
||||
viewModel := filetree.NewCommitFileTreeViewModel(
|
||||
func() []*models.CommitFile { return c.Model().CommitFiles },
|
||||
c.Log,
|
||||
@ -102,7 +102,7 @@ func (self *CommitFilesContext) renderToMain() error {
|
||||
})
|
||||
}
|
||||
|
||||
func secondaryPatchPanelUpdateOpts(c *types.HelperCommon) *types.ViewUpdateOpts {
|
||||
func secondaryPatchPanelUpdateOpts(c *ContextCommon) *types.ViewUpdateOpts {
|
||||
if c.Git().Patch.PatchBuilder.Active() {
|
||||
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
||||
|
||||
|
@ -10,13 +10,13 @@ import (
|
||||
|
||||
type CommitMessageContext struct {
|
||||
*SimpleContext
|
||||
c *types.HelperCommon
|
||||
c *ContextCommon
|
||||
}
|
||||
|
||||
var _ types.Context = (*CommitMessageContext)(nil)
|
||||
|
||||
func NewCommitMessageContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *CommitMessageContext {
|
||||
return &CommitMessageContext{
|
||||
c: c,
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
type ConfirmationContext struct {
|
||||
*SimpleContext
|
||||
c *types.HelperCommon
|
||||
c *ContextCommon
|
||||
|
||||
State ConfirmationContextState
|
||||
}
|
||||
@ -19,7 +19,7 @@ type ConfirmationContextState struct {
|
||||
var _ types.Context = (*ConfirmationContext)(nil)
|
||||
|
||||
func NewConfirmationContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *ConfirmationContext {
|
||||
return &ConfirmationContext{
|
||||
c: c,
|
||||
|
11
pkg/gui/context/context_common.go
Normal file
11
pkg/gui/context/context_common.go
Normal file
@ -0,0 +1,11 @@
|
||||
package context
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/common"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
type ContextCommon struct {
|
||||
*common.Common
|
||||
types.IGuiCommon
|
||||
}
|
@ -10,7 +10,7 @@ import (
|
||||
type ListContextTrait struct {
|
||||
types.Context
|
||||
|
||||
c *types.HelperCommon
|
||||
c *ContextCommon
|
||||
list types.IList
|
||||
getDisplayStrings func(startIdx int, length int) [][]string
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ var (
|
||||
_ types.DiffableContext = (*LocalCommitsContext)(nil)
|
||||
)
|
||||
|
||||
func NewLocalCommitsContext(c *types.HelperCommon) *LocalCommitsContext {
|
||||
func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
|
||||
viewModel := NewLocalCommitsViewModel(
|
||||
func() []*models.Commit { return c.Model().Commits },
|
||||
c,
|
||||
@ -93,7 +93,7 @@ type LocalCommitsViewModel struct {
|
||||
showWholeGitGraph bool
|
||||
}
|
||||
|
||||
func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *types.HelperCommon) *LocalCommitsViewModel {
|
||||
func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon) *LocalCommitsViewModel {
|
||||
self := &LocalCommitsViewModel{
|
||||
BasicViewModel: NewBasicViewModel(getModel),
|
||||
limitCommits: true,
|
||||
@ -141,7 +141,7 @@ func (self *LocalCommitsViewModel) GetCommits() []*models.Commit {
|
||||
return self.getModel()
|
||||
}
|
||||
|
||||
func shouldShowGraph(c *types.HelperCommon) bool {
|
||||
func shouldShowGraph(c *ContextCommon) bool {
|
||||
if c.Modes().Filtering.Active() {
|
||||
return false
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ type MenuContext struct {
|
||||
var _ types.IListContext = (*MenuContext)(nil)
|
||||
|
||||
func NewMenuContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *MenuContext {
|
||||
viewModel := NewMenuViewModel()
|
||||
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
type MergeConflictsContext struct {
|
||||
types.Context
|
||||
viewModel *ConflictsViewModel
|
||||
c *types.HelperCommon
|
||||
c *ContextCommon
|
||||
mutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ type ConflictsViewModel struct {
|
||||
}
|
||||
|
||||
func NewMergeConflictsContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *MergeConflictsContext {
|
||||
viewModel := &ConflictsViewModel{
|
||||
state: mergeconflicts.NewState(),
|
||||
|
@ -13,7 +13,7 @@ type PatchExplorerContext struct {
|
||||
state *patch_exploring.State
|
||||
viewTrait *ViewTrait
|
||||
getIncludedLineIndices func() []int
|
||||
c *types.HelperCommon
|
||||
c *ContextCommon
|
||||
mutex *deadlock.Mutex
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ func NewPatchExplorerContext(
|
||||
|
||||
getIncludedLineIndices func() []int,
|
||||
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *PatchExplorerContext {
|
||||
return &PatchExplorerContext{
|
||||
state: nil,
|
||||
|
@ -16,7 +16,7 @@ var (
|
||||
_ types.DiffableContext = (*ReflogCommitsContext)(nil)
|
||||
)
|
||||
|
||||
func NewReflogCommitsContext(c *types.HelperCommon) *ReflogCommitsContext {
|
||||
func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.Commit { return c.Model().FilteredReflogCommits })
|
||||
|
||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||
|
@ -18,7 +18,7 @@ var (
|
||||
)
|
||||
|
||||
func NewRemoteBranchesContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *RemoteBranchesContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.RemoteBranch { return c.Model().RemoteBranches })
|
||||
|
||||
|
@ -16,7 +16,7 @@ var (
|
||||
_ types.DiffableContext = (*RemotesContext)(nil)
|
||||
)
|
||||
|
||||
func NewRemotesContext(c *types.HelperCommon) *RemotesContext {
|
||||
func NewRemotesContext(c *ContextCommon) *RemotesContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.Remote { return c.Model().Remotes })
|
||||
|
||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||
|
@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
func NewStashContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *StashContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.StashEntry { return c.Model().StashEntries })
|
||||
|
||||
|
@ -22,7 +22,7 @@ var (
|
||||
)
|
||||
|
||||
func NewSubCommitsContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *SubCommitsContext {
|
||||
viewModel := &SubCommitsViewModel{
|
||||
BasicViewModel: NewBasicViewModel(
|
||||
|
@ -13,7 +13,7 @@ type SubmodulesContext struct {
|
||||
|
||||
var _ types.IListContext = (*SubmodulesContext)(nil)
|
||||
|
||||
func NewSubmodulesContext(c *types.HelperCommon) *SubmodulesContext {
|
||||
func NewSubmodulesContext(c *ContextCommon) *SubmodulesContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.SubmoduleConfig { return c.Model().Submodules })
|
||||
|
||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||
|
@ -27,7 +27,7 @@ type SuggestionsContextState struct {
|
||||
var _ types.IListContext = (*SuggestionsContext)(nil)
|
||||
|
||||
func NewSuggestionsContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *SuggestionsContext {
|
||||
state := &SuggestionsContextState{
|
||||
AsyncHandler: tasks.NewAsyncHandler(),
|
||||
|
@ -17,7 +17,7 @@ var (
|
||||
)
|
||||
|
||||
func NewTagsContext(
|
||||
c *types.HelperCommon,
|
||||
c *ContextCommon,
|
||||
) *TagsContext {
|
||||
viewModel := NewBasicViewModel(func() []*models.Tag { return c.Model().Tags })
|
||||
|
||||
|
@ -15,7 +15,7 @@ type WorkingTreeContext struct {
|
||||
|
||||
var _ types.IListContext = (*WorkingTreeContext)(nil)
|
||||
|
||||
func NewWorkingTreeContext(c *types.HelperCommon) *WorkingTreeContext {
|
||||
func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {
|
||||
viewModel := filetree.NewFileTreeViewModel(
|
||||
func() []*models.File { return c.Model().Files },
|
||||
c.Log,
|
||||
|
@ -72,14 +72,14 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
||||
"main",
|
||||
context.STAGING_MAIN_CONTEXT_KEY,
|
||||
func() []int { return nil },
|
||||
gui.c,
|
||||
gui.contextCommon,
|
||||
),
|
||||
StagingSecondary: context.NewPatchExplorerContext(
|
||||
gui.Views.StagingSecondary,
|
||||
"secondary",
|
||||
context.STAGING_SECONDARY_CONTEXT_KEY,
|
||||
func() []int { return nil },
|
||||
gui.c,
|
||||
gui.contextCommon,
|
||||
),
|
||||
CustomPatchBuilder: context.NewPatchExplorerContext(
|
||||
gui.Views.PatchBuilding,
|
||||
@ -95,7 +95,7 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
||||
|
||||
return includedLineIndices
|
||||
},
|
||||
gui.c,
|
||||
gui.contextCommon,
|
||||
),
|
||||
CustomPatchBuilderSecondary: context.NewSimpleContext(
|
||||
context.NewBaseContext(context.NewBaseContextOpts{
|
||||
@ -107,10 +107,10 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
||||
}),
|
||||
),
|
||||
MergeConflicts: context.NewMergeConflictsContext(
|
||||
gui.c,
|
||||
gui.contextCommon,
|
||||
),
|
||||
Confirmation: context.NewConfirmationContext(gui.c),
|
||||
CommitMessage: context.NewCommitMessageContext(gui.c),
|
||||
Confirmation: context.NewConfirmationContext(gui.contextCommon),
|
||||
CommitMessage: context.NewCommitMessageContext(gui.contextCommon),
|
||||
Search: context.NewSimpleContext(
|
||||
context.NewBaseContext(context.NewBaseContextOpts{
|
||||
Kind: types.PERSISTENT_POPUP,
|
||||
|
@ -40,7 +40,7 @@ func (gui *Gui) resetControllers() {
|
||||
Host: helpers.NewHostHelper(helperCommon, gui.git),
|
||||
PatchBuilding: patchBuildingHelper,
|
||||
Staging: stagingHelper,
|
||||
Bisect: helpers.NewBisectHelper(helperCommon, gui.git),
|
||||
Bisect: helpers.NewBisectHelper(helperCommon),
|
||||
Suggestions: suggestionsHelper,
|
||||
Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand),
|
||||
WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, gui.State.Contexts, refsHelper, model, setCommitMessage, getSavedCommitMessage),
|
||||
@ -50,7 +50,6 @@ func (gui *Gui) resetControllers() {
|
||||
MergeConflicts: mergeConflictsHelper,
|
||||
CherryPick: helpers.NewCherryPickHelper(
|
||||
helperCommon,
|
||||
gui.git,
|
||||
gui.State.Contexts,
|
||||
rebaseHelper,
|
||||
),
|
||||
@ -305,7 +304,7 @@ func (gui *Gui) resetControllers() {
|
||||
)
|
||||
|
||||
// this must come last so that we've got our click handlers defined against the context
|
||||
listControllerFactory := controllers.NewListControllerFactory(gui.c)
|
||||
listControllerFactory := controllers.NewListControllerFactory(common)
|
||||
for _, context := range gui.getListContexts() {
|
||||
controllers.AttachControllers(context, listControllerFactory.Create(context))
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -127,8 +127,9 @@ type Gui struct {
|
||||
|
||||
Updating bool
|
||||
|
||||
c *types.HelperCommon
|
||||
helpers *helpers.Helpers
|
||||
c *helpers.HelperCommon
|
||||
contextCommon *context.ContextCommon
|
||||
helpers *helpers.Helpers
|
||||
}
|
||||
|
||||
type StateAccessor struct {
|
||||
@ -385,6 +386,10 @@ func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartAr
|
||||
return initialContext
|
||||
}
|
||||
|
||||
func (gui *Gui) Contexts() *context.ContextTree {
|
||||
return gui.State.Contexts
|
||||
}
|
||||
|
||||
// for now the split view will always be on
|
||||
// NewGui builds a new gui handler
|
||||
func NewGui(
|
||||
@ -442,7 +447,8 @@ func NewGui(
|
||||
)
|
||||
|
||||
guiCommon := &guiCommon{gui: gui, IPopupHandler: gui.PopupHandler}
|
||||
helperCommon := &types.HelperCommon{IGuiCommon: guiCommon, Common: cmn}
|
||||
helperCommon := &helpers.HelperCommon{IGuiCommon: guiCommon, Common: cmn, IGetContexts: gui}
|
||||
contextCommon := &context.ContextCommon{IGuiCommon: guiCommon, Common: cmn}
|
||||
|
||||
credentialsHelper := helpers.NewCredentialsHelper(helperCommon)
|
||||
|
||||
@ -461,6 +467,8 @@ func NewGui(
|
||||
// TODO: reset these controllers upon changing repos due to state changing
|
||||
gui.c = helperCommon
|
||||
|
||||
gui.contextCommon = contextCommon
|
||||
|
||||
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
||||
icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons)
|
||||
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
|
||||
|
@ -6,55 +6,55 @@ import (
|
||||
)
|
||||
|
||||
func (gui *Gui) menuListContext() *context.MenuContext {
|
||||
return context.NewMenuContext(gui.c)
|
||||
return context.NewMenuContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) filesListContext() *context.WorkingTreeContext {
|
||||
return context.NewWorkingTreeContext(gui.c)
|
||||
return context.NewWorkingTreeContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) branchesListContext() *context.BranchesContext {
|
||||
return context.NewBranchesContext(gui.c)
|
||||
return context.NewBranchesContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) remotesListContext() *context.RemotesContext {
|
||||
return context.NewRemotesContext(gui.c)
|
||||
return context.NewRemotesContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) remoteBranchesListContext() *context.RemoteBranchesContext {
|
||||
return context.NewRemoteBranchesContext(gui.c)
|
||||
return context.NewRemoteBranchesContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) tagsListContext() *context.TagsContext {
|
||||
return context.NewTagsContext(gui.c)
|
||||
return context.NewTagsContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
|
||||
return context.NewLocalCommitsContext(gui.c)
|
||||
return context.NewLocalCommitsContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
|
||||
return context.NewSubCommitsContext(gui.c)
|
||||
return context.NewSubCommitsContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) reflogCommitsListContext() *context.ReflogCommitsContext {
|
||||
return context.NewReflogCommitsContext(gui.c)
|
||||
return context.NewReflogCommitsContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) stashListContext() *context.StashContext {
|
||||
return context.NewStashContext(gui.c)
|
||||
return context.NewStashContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) commitFilesListContext() *context.CommitFilesContext {
|
||||
return context.NewCommitFilesContext(gui.c)
|
||||
return context.NewCommitFilesContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) submodulesListContext() *context.SubmodulesContext {
|
||||
return context.NewSubmodulesContext(gui.c)
|
||||
return context.NewSubmodulesContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) suggestionsListContext() *context.SuggestionsContext {
|
||||
return context.NewSuggestionsContext(gui.c)
|
||||
return context.NewSuggestionsContext(gui.contextCommon)
|
||||
}
|
||||
|
||||
func (gui *Gui) getListContexts() []types.IListContext {
|
||||
|
@ -4,13 +4,14 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type OptionsMapMgr struct {
|
||||
c *types.HelperCommon
|
||||
c *helpers.HelperCommon
|
||||
}
|
||||
|
||||
func (gui *Gui) renderContextOptionsMap(c types.Context) {
|
||||
|
@ -18,7 +18,7 @@ type Client struct {
|
||||
}
|
||||
|
||||
func NewClient(
|
||||
c *types.HelperCommon,
|
||||
c *helpers.HelperCommon,
|
||||
os *oscommands.OSCommand,
|
||||
git *commands.GitCommand,
|
||||
contexts *context.ContextTree,
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||
@ -15,7 +16,7 @@ import (
|
||||
|
||||
// takes a custom command and returns a function that will be called when the corresponding user-defined keybinding is pressed
|
||||
type HandlerCreator struct {
|
||||
c *types.HelperCommon
|
||||
c *helpers.HelperCommon
|
||||
os *oscommands.OSCommand
|
||||
git *commands.GitCommand
|
||||
sessionStateLoader *SessionStateLoader
|
||||
@ -24,7 +25,7 @@ type HandlerCreator struct {
|
||||
}
|
||||
|
||||
func NewHandlerCreator(
|
||||
c *types.HelperCommon,
|
||||
c *helpers.HelperCommon,
|
||||
os *oscommands.OSCommand,
|
||||
git *commands.GitCommand,
|
||||
sessionStateLoader *SessionStateLoader,
|
||||
|
@ -15,6 +15,10 @@ import (
|
||||
)
|
||||
|
||||
type HelperCommon struct {
|
||||
*ContextCommon
|
||||
}
|
||||
|
||||
type ContextCommon struct {
|
||||
*common.Common
|
||||
IGuiCommon
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user