mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
split context common from helper common
This commit is contained in:
@ -16,7 +16,7 @@ var (
|
|||||||
_ types.DiffableContext = (*BranchesContext)(nil)
|
_ types.DiffableContext = (*BranchesContext)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewBranchesContext(c *types.HelperCommon) *BranchesContext {
|
func NewBranchesContext(c *ContextCommon) *BranchesContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.Branch { return c.Model().Branches })
|
viewModel := NewBasicViewModel(func() []*models.Branch { return c.Model().Branches })
|
||||||
|
|
||||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||||
|
@ -20,7 +20,7 @@ var (
|
|||||||
_ types.DiffableContext = (*CommitFilesContext)(nil)
|
_ types.DiffableContext = (*CommitFilesContext)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewCommitFilesContext(c *types.HelperCommon) *CommitFilesContext {
|
func NewCommitFilesContext(c *ContextCommon) *CommitFilesContext {
|
||||||
viewModel := filetree.NewCommitFileTreeViewModel(
|
viewModel := filetree.NewCommitFileTreeViewModel(
|
||||||
func() []*models.CommitFile { return c.Model().CommitFiles },
|
func() []*models.CommitFile { return c.Model().CommitFiles },
|
||||||
c.Log,
|
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() {
|
if c.Git().Patch.PatchBuilder.Active() {
|
||||||
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
||||||
|
|
||||||
|
@ -10,13 +10,13 @@ import (
|
|||||||
|
|
||||||
type CommitMessageContext struct {
|
type CommitMessageContext struct {
|
||||||
*SimpleContext
|
*SimpleContext
|
||||||
c *types.HelperCommon
|
c *ContextCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ types.Context = (*CommitMessageContext)(nil)
|
var _ types.Context = (*CommitMessageContext)(nil)
|
||||||
|
|
||||||
func NewCommitMessageContext(
|
func NewCommitMessageContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *CommitMessageContext {
|
) *CommitMessageContext {
|
||||||
return &CommitMessageContext{
|
return &CommitMessageContext{
|
||||||
c: c,
|
c: c,
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
type ConfirmationContext struct {
|
type ConfirmationContext struct {
|
||||||
*SimpleContext
|
*SimpleContext
|
||||||
c *types.HelperCommon
|
c *ContextCommon
|
||||||
|
|
||||||
State ConfirmationContextState
|
State ConfirmationContextState
|
||||||
}
|
}
|
||||||
@ -19,7 +19,7 @@ type ConfirmationContextState struct {
|
|||||||
var _ types.Context = (*ConfirmationContext)(nil)
|
var _ types.Context = (*ConfirmationContext)(nil)
|
||||||
|
|
||||||
func NewConfirmationContext(
|
func NewConfirmationContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *ConfirmationContext {
|
) *ConfirmationContext {
|
||||||
return &ConfirmationContext{
|
return &ConfirmationContext{
|
||||||
c: c,
|
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 {
|
type ListContextTrait struct {
|
||||||
types.Context
|
types.Context
|
||||||
|
|
||||||
c *types.HelperCommon
|
c *ContextCommon
|
||||||
list types.IList
|
list types.IList
|
||||||
getDisplayStrings func(startIdx int, length int) [][]string
|
getDisplayStrings func(startIdx int, length int) [][]string
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ var (
|
|||||||
_ types.DiffableContext = (*LocalCommitsContext)(nil)
|
_ types.DiffableContext = (*LocalCommitsContext)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewLocalCommitsContext(c *types.HelperCommon) *LocalCommitsContext {
|
func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
|
||||||
viewModel := NewLocalCommitsViewModel(
|
viewModel := NewLocalCommitsViewModel(
|
||||||
func() []*models.Commit { return c.Model().Commits },
|
func() []*models.Commit { return c.Model().Commits },
|
||||||
c,
|
c,
|
||||||
@ -93,7 +93,7 @@ type LocalCommitsViewModel struct {
|
|||||||
showWholeGitGraph bool
|
showWholeGitGraph bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *types.HelperCommon) *LocalCommitsViewModel {
|
func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon) *LocalCommitsViewModel {
|
||||||
self := &LocalCommitsViewModel{
|
self := &LocalCommitsViewModel{
|
||||||
BasicViewModel: NewBasicViewModel(getModel),
|
BasicViewModel: NewBasicViewModel(getModel),
|
||||||
limitCommits: true,
|
limitCommits: true,
|
||||||
@ -141,7 +141,7 @@ func (self *LocalCommitsViewModel) GetCommits() []*models.Commit {
|
|||||||
return self.getModel()
|
return self.getModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldShowGraph(c *types.HelperCommon) bool {
|
func shouldShowGraph(c *ContextCommon) bool {
|
||||||
if c.Modes().Filtering.Active() {
|
if c.Modes().Filtering.Active() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ type MenuContext struct {
|
|||||||
var _ types.IListContext = (*MenuContext)(nil)
|
var _ types.IListContext = (*MenuContext)(nil)
|
||||||
|
|
||||||
func NewMenuContext(
|
func NewMenuContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *MenuContext {
|
) *MenuContext {
|
||||||
viewModel := NewMenuViewModel()
|
viewModel := NewMenuViewModel()
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
type MergeConflictsContext struct {
|
type MergeConflictsContext struct {
|
||||||
types.Context
|
types.Context
|
||||||
viewModel *ConflictsViewModel
|
viewModel *ConflictsViewModel
|
||||||
c *types.HelperCommon
|
c *ContextCommon
|
||||||
mutex *deadlock.Mutex
|
mutex *deadlock.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ type ConflictsViewModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewMergeConflictsContext(
|
func NewMergeConflictsContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *MergeConflictsContext {
|
) *MergeConflictsContext {
|
||||||
viewModel := &ConflictsViewModel{
|
viewModel := &ConflictsViewModel{
|
||||||
state: mergeconflicts.NewState(),
|
state: mergeconflicts.NewState(),
|
||||||
|
@ -13,7 +13,7 @@ type PatchExplorerContext struct {
|
|||||||
state *patch_exploring.State
|
state *patch_exploring.State
|
||||||
viewTrait *ViewTrait
|
viewTrait *ViewTrait
|
||||||
getIncludedLineIndices func() []int
|
getIncludedLineIndices func() []int
|
||||||
c *types.HelperCommon
|
c *ContextCommon
|
||||||
mutex *deadlock.Mutex
|
mutex *deadlock.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ func NewPatchExplorerContext(
|
|||||||
|
|
||||||
getIncludedLineIndices func() []int,
|
getIncludedLineIndices func() []int,
|
||||||
|
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *PatchExplorerContext {
|
) *PatchExplorerContext {
|
||||||
return &PatchExplorerContext{
|
return &PatchExplorerContext{
|
||||||
state: nil,
|
state: nil,
|
||||||
|
@ -16,7 +16,7 @@ var (
|
|||||||
_ types.DiffableContext = (*ReflogCommitsContext)(nil)
|
_ types.DiffableContext = (*ReflogCommitsContext)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewReflogCommitsContext(c *types.HelperCommon) *ReflogCommitsContext {
|
func NewReflogCommitsContext(c *ContextCommon) *ReflogCommitsContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.Commit { return c.Model().FilteredReflogCommits })
|
viewModel := NewBasicViewModel(func() []*models.Commit { return c.Model().FilteredReflogCommits })
|
||||||
|
|
||||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||||
|
@ -18,7 +18,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewRemoteBranchesContext(
|
func NewRemoteBranchesContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *RemoteBranchesContext {
|
) *RemoteBranchesContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.RemoteBranch { return c.Model().RemoteBranches })
|
viewModel := NewBasicViewModel(func() []*models.RemoteBranch { return c.Model().RemoteBranches })
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ var (
|
|||||||
_ types.DiffableContext = (*RemotesContext)(nil)
|
_ types.DiffableContext = (*RemotesContext)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewRemotesContext(c *types.HelperCommon) *RemotesContext {
|
func NewRemotesContext(c *ContextCommon) *RemotesContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.Remote { return c.Model().Remotes })
|
viewModel := NewBasicViewModel(func() []*models.Remote { return c.Model().Remotes })
|
||||||
|
|
||||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||||
|
@ -17,7 +17,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewStashContext(
|
func NewStashContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *StashContext {
|
) *StashContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.StashEntry { return c.Model().StashEntries })
|
viewModel := NewBasicViewModel(func() []*models.StashEntry { return c.Model().StashEntries })
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewSubCommitsContext(
|
func NewSubCommitsContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *SubCommitsContext {
|
) *SubCommitsContext {
|
||||||
viewModel := &SubCommitsViewModel{
|
viewModel := &SubCommitsViewModel{
|
||||||
BasicViewModel: NewBasicViewModel(
|
BasicViewModel: NewBasicViewModel(
|
||||||
|
@ -13,7 +13,7 @@ type SubmodulesContext struct {
|
|||||||
|
|
||||||
var _ types.IListContext = (*SubmodulesContext)(nil)
|
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 })
|
viewModel := NewBasicViewModel(func() []*models.SubmoduleConfig { return c.Model().Submodules })
|
||||||
|
|
||||||
getDisplayStrings := func(startIdx int, length int) [][]string {
|
getDisplayStrings := func(startIdx int, length int) [][]string {
|
||||||
|
@ -27,7 +27,7 @@ type SuggestionsContextState struct {
|
|||||||
var _ types.IListContext = (*SuggestionsContext)(nil)
|
var _ types.IListContext = (*SuggestionsContext)(nil)
|
||||||
|
|
||||||
func NewSuggestionsContext(
|
func NewSuggestionsContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *SuggestionsContext {
|
) *SuggestionsContext {
|
||||||
state := &SuggestionsContextState{
|
state := &SuggestionsContextState{
|
||||||
AsyncHandler: tasks.NewAsyncHandler(),
|
AsyncHandler: tasks.NewAsyncHandler(),
|
||||||
|
@ -17,7 +17,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewTagsContext(
|
func NewTagsContext(
|
||||||
c *types.HelperCommon,
|
c *ContextCommon,
|
||||||
) *TagsContext {
|
) *TagsContext {
|
||||||
viewModel := NewBasicViewModel(func() []*models.Tag { return c.Model().Tags })
|
viewModel := NewBasicViewModel(func() []*models.Tag { return c.Model().Tags })
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ type WorkingTreeContext struct {
|
|||||||
|
|
||||||
var _ types.IListContext = (*WorkingTreeContext)(nil)
|
var _ types.IListContext = (*WorkingTreeContext)(nil)
|
||||||
|
|
||||||
func NewWorkingTreeContext(c *types.HelperCommon) *WorkingTreeContext {
|
func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {
|
||||||
viewModel := filetree.NewFileTreeViewModel(
|
viewModel := filetree.NewFileTreeViewModel(
|
||||||
func() []*models.File { return c.Model().Files },
|
func() []*models.File { return c.Model().Files },
|
||||||
c.Log,
|
c.Log,
|
||||||
|
@ -72,14 +72,14 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
|||||||
"main",
|
"main",
|
||||||
context.STAGING_MAIN_CONTEXT_KEY,
|
context.STAGING_MAIN_CONTEXT_KEY,
|
||||||
func() []int { return nil },
|
func() []int { return nil },
|
||||||
gui.c,
|
gui.contextCommon,
|
||||||
),
|
),
|
||||||
StagingSecondary: context.NewPatchExplorerContext(
|
StagingSecondary: context.NewPatchExplorerContext(
|
||||||
gui.Views.StagingSecondary,
|
gui.Views.StagingSecondary,
|
||||||
"secondary",
|
"secondary",
|
||||||
context.STAGING_SECONDARY_CONTEXT_KEY,
|
context.STAGING_SECONDARY_CONTEXT_KEY,
|
||||||
func() []int { return nil },
|
func() []int { return nil },
|
||||||
gui.c,
|
gui.contextCommon,
|
||||||
),
|
),
|
||||||
CustomPatchBuilder: context.NewPatchExplorerContext(
|
CustomPatchBuilder: context.NewPatchExplorerContext(
|
||||||
gui.Views.PatchBuilding,
|
gui.Views.PatchBuilding,
|
||||||
@ -95,7 +95,7 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
|||||||
|
|
||||||
return includedLineIndices
|
return includedLineIndices
|
||||||
},
|
},
|
||||||
gui.c,
|
gui.contextCommon,
|
||||||
),
|
),
|
||||||
CustomPatchBuilderSecondary: context.NewSimpleContext(
|
CustomPatchBuilderSecondary: context.NewSimpleContext(
|
||||||
context.NewBaseContext(context.NewBaseContextOpts{
|
context.NewBaseContext(context.NewBaseContextOpts{
|
||||||
@ -107,10 +107,10 @@ func (gui *Gui) contextTree() *context.ContextTree {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
MergeConflicts: context.NewMergeConflictsContext(
|
MergeConflicts: context.NewMergeConflictsContext(
|
||||||
gui.c,
|
gui.contextCommon,
|
||||||
),
|
),
|
||||||
Confirmation: context.NewConfirmationContext(gui.c),
|
Confirmation: context.NewConfirmationContext(gui.contextCommon),
|
||||||
CommitMessage: context.NewCommitMessageContext(gui.c),
|
CommitMessage: context.NewCommitMessageContext(gui.contextCommon),
|
||||||
Search: context.NewSimpleContext(
|
Search: context.NewSimpleContext(
|
||||||
context.NewBaseContext(context.NewBaseContextOpts{
|
context.NewBaseContext(context.NewBaseContextOpts{
|
||||||
Kind: types.PERSISTENT_POPUP,
|
Kind: types.PERSISTENT_POPUP,
|
||||||
|
@ -40,7 +40,7 @@ func (gui *Gui) resetControllers() {
|
|||||||
Host: helpers.NewHostHelper(helperCommon, gui.git),
|
Host: helpers.NewHostHelper(helperCommon, gui.git),
|
||||||
PatchBuilding: patchBuildingHelper,
|
PatchBuilding: patchBuildingHelper,
|
||||||
Staging: stagingHelper,
|
Staging: stagingHelper,
|
||||||
Bisect: helpers.NewBisectHelper(helperCommon, gui.git),
|
Bisect: helpers.NewBisectHelper(helperCommon),
|
||||||
Suggestions: suggestionsHelper,
|
Suggestions: suggestionsHelper,
|
||||||
Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand),
|
Files: helpers.NewFilesHelper(helperCommon, gui.git, osCommand),
|
||||||
WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, gui.State.Contexts, refsHelper, model, setCommitMessage, getSavedCommitMessage),
|
WorkingTree: helpers.NewWorkingTreeHelper(helperCommon, gui.git, gui.State.Contexts, refsHelper, model, setCommitMessage, getSavedCommitMessage),
|
||||||
@ -50,7 +50,6 @@ func (gui *Gui) resetControllers() {
|
|||||||
MergeConflicts: mergeConflictsHelper,
|
MergeConflicts: mergeConflictsHelper,
|
||||||
CherryPick: helpers.NewCherryPickHelper(
|
CherryPick: helpers.NewCherryPickHelper(
|
||||||
helperCommon,
|
helperCommon,
|
||||||
gui.git,
|
|
||||||
gui.State.Contexts,
|
gui.State.Contexts,
|
||||||
rebaseHelper,
|
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
|
// 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() {
|
for _, context := range gui.getListContexts() {
|
||||||
controllers.AttachControllers(context, listControllerFactory.Create(context))
|
controllers.AttachControllers(context, listControllerFactory.Create(context))
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type controllerCommon struct {
|
type controllerCommon struct {
|
||||||
c *types.HelperCommon
|
c *helpers.HelperCommon
|
||||||
helpers *helpers.Helpers
|
helpers *helpers.Helpers
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ type controllerCommon struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewControllerCommon(
|
func NewControllerCommon(
|
||||||
c *types.HelperCommon,
|
c *helpers.HelperCommon,
|
||||||
os *oscommands.OSCommand,
|
os *oscommands.OSCommand,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
helpers *helpers.Helpers,
|
helpers *helpers.Helpers,
|
||||||
|
@ -1,23 +1,15 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BisectHelper struct {
|
type BisectHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBisectHelper(
|
func NewBisectHelper(c *HelperCommon) *BisectHelper {
|
||||||
c *types.HelperCommon,
|
return &BisectHelper{c: c}
|
||||||
git *commands.GitCommand,
|
|
||||||
) *BisectHelper {
|
|
||||||
return &BisectHelper{
|
|
||||||
c: c,
|
|
||||||
git: git,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *BisectHelper) Reset() error {
|
func (self *BisectHelper) Reset() error {
|
||||||
@ -26,7 +18,7 @@ func (self *BisectHelper) Reset() error {
|
|||||||
Prompt: self.c.Tr.Bisect.ResetPrompt,
|
Prompt: self.c.Tr.Bisect.ResetPrompt,
|
||||||
HandleConfirm: func() error {
|
HandleConfirm: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.ResetBisect)
|
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)
|
return self.c.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package helpers
|
package helpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
|
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
|
||||||
@ -9,9 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CherryPickHelper struct {
|
type CherryPickHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
|
|
||||||
git *commands.GitCommand
|
|
||||||
|
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
|
|
||||||
@ -22,14 +19,12 @@ type CherryPickHelper struct {
|
|||||||
// even if in truth we're running git cherry-pick
|
// even if in truth we're running git cherry-pick
|
||||||
|
|
||||||
func NewCherryPickHelper(
|
func NewCherryPickHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
rebaseHelper *MergeAndRebaseHelper,
|
rebaseHelper *MergeAndRebaseHelper,
|
||||||
) *CherryPickHelper {
|
) *CherryPickHelper {
|
||||||
return &CherryPickHelper{
|
return &CherryPickHelper{
|
||||||
c: c,
|
c: c,
|
||||||
git: git,
|
|
||||||
contexts: contexts,
|
contexts: contexts,
|
||||||
rebaseHelper: rebaseHelper,
|
rebaseHelper: rebaseHelper,
|
||||||
}
|
}
|
||||||
@ -87,7 +82,7 @@ func (self *CherryPickHelper) Paste() error {
|
|||||||
HandleConfirm: func() error {
|
HandleConfirm: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func() error {
|
return self.c.WithWaitingStatus(self.c.Tr.CherryPickingStatus, func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.CherryPick)
|
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)
|
return self.rebaseHelper.CheckMergeOrRebase(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -15,12 +15,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ConfirmationHelper struct {
|
type ConfirmationHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfirmationHelper(
|
func NewConfirmationHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
) *ConfirmationHelper {
|
) *ConfirmationHelper {
|
||||||
return &ConfirmationHelper{
|
return &ConfirmationHelper{
|
||||||
|
@ -8,11 +8,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type CredentialsHelper struct {
|
type CredentialsHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCredentialsHelper(
|
func NewCredentialsHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
) *CredentialsHelper {
|
) *CredentialsHelper {
|
||||||
return &CredentialsHelper{
|
return &CredentialsHelper{
|
||||||
c: c,
|
c: c,
|
||||||
|
@ -10,10 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DiffHelper struct {
|
type DiffHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDiffHelper(c *types.HelperCommon) *DiffHelper {
|
func NewDiffHelper(c *HelperCommon) *DiffHelper {
|
||||||
return &DiffHelper{
|
return &DiffHelper{
|
||||||
c: c,
|
c: c,
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package helpers
|
|||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type IFilesHelper interface {
|
type IFilesHelper interface {
|
||||||
@ -13,13 +12,13 @@ type IFilesHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FilesHelper struct {
|
type FilesHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
os *oscommands.OSCommand
|
os *oscommands.OSCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFilesHelper(
|
func NewFilesHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
os *oscommands.OSCommand,
|
os *oscommands.OSCommand,
|
||||||
) *FilesHelper {
|
) *FilesHelper {
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type GpgHelper struct {
|
type GpgHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
os *oscommands.OSCommand
|
os *oscommands.OSCommand
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGpgHelper(
|
func NewGpgHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
os *oscommands.OSCommand,
|
os *oscommands.OSCommand,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
) *GpgHelper {
|
) *GpgHelper {
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
package helpers
|
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 {
|
type Helpers struct {
|
||||||
Refs *RefsHelper
|
Refs *RefsHelper
|
||||||
Bisect *BisectHelper
|
Bisect *BisectHelper
|
||||||
|
@ -3,7 +3,6 @@ package helpers
|
|||||||
import (
|
import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/hosting_service"
|
"github.com/jesseduffield/lazygit/pkg/commands/hosting_service"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// this helper just wraps our hosting_service package
|
// this helper just wraps our hosting_service package
|
||||||
@ -14,12 +13,12 @@ type IHostHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HostHelper struct {
|
type HostHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHostHelper(
|
func NewHostHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
) *HostHelper {
|
) *HostHelper {
|
||||||
return &HostHelper{
|
return &HostHelper{
|
||||||
|
@ -14,14 +14,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MergeAndRebaseHelper struct {
|
type MergeAndRebaseHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
refsHelper *RefsHelper
|
refsHelper *RefsHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMergeAndRebaseHelper(
|
func NewMergeAndRebaseHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
refsHelper *RefsHelper,
|
refsHelper *RefsHelper,
|
||||||
|
@ -7,13 +7,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MergeConflictsHelper struct {
|
type MergeConflictsHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMergeConflictsHelper(
|
func NewMergeConflictsHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
) *MergeConflictsHelper {
|
) *MergeConflictsHelper {
|
||||||
|
@ -13,13 +13,13 @@ type IPatchBuildingHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PatchBuildingHelper struct {
|
type PatchBuildingHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPatchBuildingHelper(
|
func NewPatchBuildingHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
) *PatchBuildingHelper {
|
) *PatchBuildingHelper {
|
||||||
|
@ -2,15 +2,13 @@ package helpers
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type RecordDirectoryHelper struct {
|
type RecordDirectoryHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRecordDirectoryHelper(c *types.HelperCommon) *RecordDirectoryHelper {
|
func NewRecordDirectoryHelper(c *HelperCommon) *RecordDirectoryHelper {
|
||||||
return &RecordDirectoryHelper{
|
return &RecordDirectoryHelper{
|
||||||
c: c,
|
c: c,
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type RefreshHelper struct {
|
type RefreshHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
refsHelper *RefsHelper
|
refsHelper *RefsHelper
|
||||||
@ -33,7 +33,7 @@ type RefreshHelper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewRefreshHelper(
|
func NewRefreshHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
refsHelper *RefsHelper,
|
refsHelper *RefsHelper,
|
||||||
|
@ -23,14 +23,14 @@ type IRefsHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type RefsHelper struct {
|
type RefsHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
model *types.Model
|
model *types.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRefsHelper(
|
func NewRefsHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
model *types.Model,
|
model *types.Model,
|
||||||
|
@ -22,13 +22,13 @@ type onNewRepoFn func(startArgs appTypes.StartArgs, reuseState bool) error
|
|||||||
|
|
||||||
// helps switch back and forth between repos
|
// helps switch back and forth between repos
|
||||||
type ReposHelper struct {
|
type ReposHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
recordDirectoryHelper *RecordDirectoryHelper
|
recordDirectoryHelper *RecordDirectoryHelper
|
||||||
onNewRepo onNewRepoFn
|
onNewRepo onNewRepoFn
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewRecentReposHelper(
|
func NewRecentReposHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
recordDirectoryHelper *RecordDirectoryHelper,
|
recordDirectoryHelper *RecordDirectoryHelper,
|
||||||
onNewRepo onNewRepoFn,
|
onNewRepo onNewRepoFn,
|
||||||
) *ReposHelper {
|
) *ReposHelper {
|
||||||
|
@ -5,16 +5,15 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/snake"
|
"github.com/jesseduffield/lazygit/pkg/snake"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SnakeHelper struct {
|
type SnakeHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
game *snake.Game
|
game *snake.Game
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSnakeHelper(c *types.HelperCommon) *SnakeHelper {
|
func NewSnakeHelper(c *HelperCommon) *SnakeHelper {
|
||||||
return &SnakeHelper{
|
return &SnakeHelper{
|
||||||
c: c,
|
c: c,
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type StagingHelper struct {
|
type StagingHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStagingHelper(
|
func NewStagingHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
) *StagingHelper {
|
) *StagingHelper {
|
||||||
|
@ -34,7 +34,7 @@ type ISuggestionsHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SuggestionsHelper struct {
|
type SuggestionsHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
|
|
||||||
model *types.Model
|
model *types.Model
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
@ -43,7 +43,7 @@ type SuggestionsHelper struct {
|
|||||||
var _ ISuggestionsHelper = &SuggestionsHelper{}
|
var _ ISuggestionsHelper = &SuggestionsHelper{}
|
||||||
|
|
||||||
func NewSuggestionsHelper(
|
func NewSuggestionsHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
model *types.Model,
|
model *types.Model,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
) *SuggestionsHelper {
|
) *SuggestionsHelper {
|
||||||
|
@ -10,11 +10,11 @@ import (
|
|||||||
// and the commits context.
|
// and the commits context.
|
||||||
|
|
||||||
type TagsHelper struct {
|
type TagsHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTagsHelper(c *types.HelperCommon, git *commands.GitCommand) *TagsHelper {
|
func NewTagsHelper(c *HelperCommon, git *commands.GitCommand) *TagsHelper {
|
||||||
return &TagsHelper{
|
return &TagsHelper{
|
||||||
c: c,
|
c: c,
|
||||||
git: git,
|
git: git,
|
||||||
|
@ -7,11 +7,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UpdateHelper struct {
|
type UpdateHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
updater *updates.Updater
|
updater *updates.Updater
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUpdateHelper(c *types.HelperCommon, updater *updates.Updater) *UpdateHelper {
|
func NewUpdateHelper(c *HelperCommon, updater *updates.Updater) *UpdateHelper {
|
||||||
return &UpdateHelper{
|
return &UpdateHelper{
|
||||||
c: c,
|
c: c,
|
||||||
updater: updater,
|
updater: updater,
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type UpstreamHelper struct {
|
type UpstreamHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
model *types.Model
|
model *types.Model
|
||||||
|
|
||||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion
|
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion
|
||||||
@ -25,7 +25,7 @@ type IUpstreamHelper interface {
|
|||||||
var _ IUpstreamHelper = &UpstreamHelper{}
|
var _ IUpstreamHelper = &UpstreamHelper{}
|
||||||
|
|
||||||
func NewUpstreamHelper(
|
func NewUpstreamHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
model *types.Model,
|
model *types.Model,
|
||||||
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion,
|
getRemoteBranchesSuggestionsFunc func(string) func(string) []*types.Suggestion,
|
||||||
) *UpstreamHelper {
|
) *UpstreamHelper {
|
||||||
|
@ -6,11 +6,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ViewHelper struct {
|
type ViewHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewViewHelper(c *types.HelperCommon, contexts *context.ContextTree) *ViewHelper {
|
func NewViewHelper(c *HelperCommon, contexts *context.ContextTree) *ViewHelper {
|
||||||
return &ViewHelper{
|
return &ViewHelper{
|
||||||
c: c,
|
c: c,
|
||||||
contexts: contexts,
|
contexts: contexts,
|
||||||
|
@ -11,12 +11,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type WindowHelper struct {
|
type WindowHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
viewHelper *ViewHelper
|
viewHelper *ViewHelper
|
||||||
contexts *context.ContextTree
|
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{
|
return &WindowHelper{
|
||||||
c: c,
|
c: c,
|
||||||
viewHelper: viewHelper,
|
viewHelper: viewHelper,
|
||||||
|
@ -20,7 +20,7 @@ type IWorkingTreeHelper interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type WorkingTreeHelper struct {
|
type WorkingTreeHelper struct {
|
||||||
c *types.HelperCommon
|
c *HelperCommon
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
contexts *context.ContextTree
|
contexts *context.ContextTree
|
||||||
refHelper *RefsHelper
|
refHelper *RefsHelper
|
||||||
@ -30,7 +30,7 @@ type WorkingTreeHelper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewWorkingTreeHelper(
|
func NewWorkingTreeHelper(
|
||||||
c *types.HelperCommon,
|
c *HelperCommon,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
refHelper *RefsHelper,
|
refHelper *RefsHelper,
|
||||||
|
@ -6,26 +6,26 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ListControllerFactory struct {
|
type ListControllerFactory struct {
|
||||||
c *types.HelperCommon
|
*controllerCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewListControllerFactory(c *types.HelperCommon) *ListControllerFactory {
|
func NewListControllerFactory(c *controllerCommon) *ListControllerFactory {
|
||||||
return &ListControllerFactory{
|
return &ListControllerFactory{
|
||||||
c: c,
|
controllerCommon: c,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ListControllerFactory) Create(context types.IListContext) *ListController {
|
func (self *ListControllerFactory) Create(context types.IListContext) *ListController {
|
||||||
return &ListController{
|
return &ListController{
|
||||||
baseController: baseController{},
|
baseController: baseController{},
|
||||||
c: self.c,
|
controllerCommon: self.controllerCommon,
|
||||||
context: context,
|
context: context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListController struct {
|
type ListController struct {
|
||||||
baseController
|
baseController
|
||||||
c *types.HelperCommon
|
*controllerCommon
|
||||||
|
|
||||||
context types.IListContext
|
context types.IListContext
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"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/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/samber/lo"
|
"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() {
|
if c.Git().Patch.PatchBuilder.Active() {
|
||||||
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
patch := c.Git().Patch.PatchBuilder.RenderAggregatedPatch(false)
|
||||||
|
|
||||||
|
@ -127,7 +127,8 @@ type Gui struct {
|
|||||||
|
|
||||||
Updating bool
|
Updating bool
|
||||||
|
|
||||||
c *types.HelperCommon
|
c *helpers.HelperCommon
|
||||||
|
contextCommon *context.ContextCommon
|
||||||
helpers *helpers.Helpers
|
helpers *helpers.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,6 +386,10 @@ func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartAr
|
|||||||
return initialContext
|
return initialContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) Contexts() *context.ContextTree {
|
||||||
|
return gui.State.Contexts
|
||||||
|
}
|
||||||
|
|
||||||
// for now the split view will always be on
|
// for now the split view will always be on
|
||||||
// NewGui builds a new gui handler
|
// NewGui builds a new gui handler
|
||||||
func NewGui(
|
func NewGui(
|
||||||
@ -442,7 +447,8 @@ func NewGui(
|
|||||||
)
|
)
|
||||||
|
|
||||||
guiCommon := &guiCommon{gui: gui, IPopupHandler: gui.PopupHandler}
|
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)
|
credentialsHelper := helpers.NewCredentialsHelper(helperCommon)
|
||||||
|
|
||||||
@ -461,6 +467,8 @@ func NewGui(
|
|||||||
// TODO: reset these controllers upon changing repos due to state changing
|
// TODO: reset these controllers upon changing repos due to state changing
|
||||||
gui.c = helperCommon
|
gui.c = helperCommon
|
||||||
|
|
||||||
|
gui.contextCommon = contextCommon
|
||||||
|
|
||||||
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
||||||
icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons)
|
icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons)
|
||||||
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
|
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
|
||||||
|
@ -6,55 +6,55 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (gui *Gui) menuListContext() *context.MenuContext {
|
func (gui *Gui) menuListContext() *context.MenuContext {
|
||||||
return context.NewMenuContext(gui.c)
|
return context.NewMenuContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) filesListContext() *context.WorkingTreeContext {
|
func (gui *Gui) filesListContext() *context.WorkingTreeContext {
|
||||||
return context.NewWorkingTreeContext(gui.c)
|
return context.NewWorkingTreeContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) branchesListContext() *context.BranchesContext {
|
func (gui *Gui) branchesListContext() *context.BranchesContext {
|
||||||
return context.NewBranchesContext(gui.c)
|
return context.NewBranchesContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) remotesListContext() *context.RemotesContext {
|
func (gui *Gui) remotesListContext() *context.RemotesContext {
|
||||||
return context.NewRemotesContext(gui.c)
|
return context.NewRemotesContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) remoteBranchesListContext() *context.RemoteBranchesContext {
|
func (gui *Gui) remoteBranchesListContext() *context.RemoteBranchesContext {
|
||||||
return context.NewRemoteBranchesContext(gui.c)
|
return context.NewRemoteBranchesContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) tagsListContext() *context.TagsContext {
|
func (gui *Gui) tagsListContext() *context.TagsContext {
|
||||||
return context.NewTagsContext(gui.c)
|
return context.NewTagsContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
|
func (gui *Gui) branchCommitsListContext() *context.LocalCommitsContext {
|
||||||
return context.NewLocalCommitsContext(gui.c)
|
return context.NewLocalCommitsContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
|
func (gui *Gui) subCommitsListContext() *context.SubCommitsContext {
|
||||||
return context.NewSubCommitsContext(gui.c)
|
return context.NewSubCommitsContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) reflogCommitsListContext() *context.ReflogCommitsContext {
|
func (gui *Gui) reflogCommitsListContext() *context.ReflogCommitsContext {
|
||||||
return context.NewReflogCommitsContext(gui.c)
|
return context.NewReflogCommitsContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) stashListContext() *context.StashContext {
|
func (gui *Gui) stashListContext() *context.StashContext {
|
||||||
return context.NewStashContext(gui.c)
|
return context.NewStashContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) commitFilesListContext() *context.CommitFilesContext {
|
func (gui *Gui) commitFilesListContext() *context.CommitFilesContext {
|
||||||
return context.NewCommitFilesContext(gui.c)
|
return context.NewCommitFilesContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) submodulesListContext() *context.SubmodulesContext {
|
func (gui *Gui) submodulesListContext() *context.SubmodulesContext {
|
||||||
return context.NewSubmodulesContext(gui.c)
|
return context.NewSubmodulesContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) suggestionsListContext() *context.SuggestionsContext {
|
func (gui *Gui) suggestionsListContext() *context.SuggestionsContext {
|
||||||
return context.NewSuggestionsContext(gui.c)
|
return context.NewSuggestionsContext(gui.contextCommon)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) getListContexts() []types.IListContext {
|
func (gui *Gui) getListContexts() []types.IListContext {
|
||||||
|
@ -4,13 +4,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
|
"github.com/jesseduffield/lazygit/pkg/gui/keybindings"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OptionsMapMgr struct {
|
type OptionsMapMgr struct {
|
||||||
c *types.HelperCommon
|
c *helpers.HelperCommon
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) renderContextOptionsMap(c types.Context) {
|
func (gui *Gui) renderContextOptionsMap(c types.Context) {
|
||||||
|
@ -18,7 +18,7 @@ type Client struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(
|
func NewClient(
|
||||||
c *types.HelperCommon,
|
c *helpers.HelperCommon,
|
||||||
os *oscommands.OSCommand,
|
os *oscommands.OSCommand,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
contexts *context.ContextTree,
|
contexts *context.ContextTree,
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands"
|
"github.com/jesseduffield/lazygit/pkg/commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"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/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"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
|
// takes a custom command and returns a function that will be called when the corresponding user-defined keybinding is pressed
|
||||||
type HandlerCreator struct {
|
type HandlerCreator struct {
|
||||||
c *types.HelperCommon
|
c *helpers.HelperCommon
|
||||||
os *oscommands.OSCommand
|
os *oscommands.OSCommand
|
||||||
git *commands.GitCommand
|
git *commands.GitCommand
|
||||||
sessionStateLoader *SessionStateLoader
|
sessionStateLoader *SessionStateLoader
|
||||||
@ -24,7 +25,7 @@ type HandlerCreator struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewHandlerCreator(
|
func NewHandlerCreator(
|
||||||
c *types.HelperCommon,
|
c *helpers.HelperCommon,
|
||||||
os *oscommands.OSCommand,
|
os *oscommands.OSCommand,
|
||||||
git *commands.GitCommand,
|
git *commands.GitCommand,
|
||||||
sessionStateLoader *SessionStateLoader,
|
sessionStateLoader *SessionStateLoader,
|
||||||
|
@ -15,6 +15,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type HelperCommon struct {
|
type HelperCommon struct {
|
||||||
|
*ContextCommon
|
||||||
|
}
|
||||||
|
|
||||||
|
type ContextCommon struct {
|
||||||
*common.Common
|
*common.Common
|
||||||
IGuiCommon
|
IGuiCommon
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user