summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-03-23 12:35:07 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 13:19:53 +1000
commit43251e727596cca2538548976769e47a1bfc5593 (patch)
tree280e4f0609ca58bbbaeb80446fa0d14a7e58a993
parentf08135894344583394240f240377015ea874b03b (diff)
split context common from helper common
-rw-r--r--pkg/gui/context/branches_context.go2
-rw-r--r--pkg/gui/context/commit_files_context.go4
-rw-r--r--pkg/gui/context/commit_message_context.go4
-rw-r--r--pkg/gui/context/confirmation_context.go4
-rw-r--r--pkg/gui/context/context_common.go11
-rw-r--r--pkg/gui/context/list_context_trait.go2
-rw-r--r--pkg/gui/context/local_commits_context.go6
-rw-r--r--pkg/gui/context/menu_context.go2
-rw-r--r--pkg/gui/context/merge_conflicts_context.go4
-rw-r--r--pkg/gui/context/patch_explorer_context.go4
-rw-r--r--pkg/gui/context/reflog_commits_context.go2
-rw-r--r--pkg/gui/context/remote_branches_context.go2
-rw-r--r--pkg/gui/context/remotes_context.go2
-rw-r--r--pkg/gui/context/stash_context.go2
-rw-r--r--pkg/gui/context/sub_commits_context.go2
-rw-r--r--pkg/gui/context/submodules_context.go2
-rw-r--r--pkg/gui/context/suggestions_context.go2
-rw-r--r--pkg/gui/context/tags_context.go2
-rw-r--r--pkg/gui/context/working_tree_context.go2
-rw-r--r--pkg/gui/context_config.go12
-rw-r--r--pkg/gui/controllers.go5
-rw-r--r--pkg/gui/controllers/common.go4
-rw-r--r--pkg/gui/controllers/helpers/bisect_helper.go16
-rw-r--r--pkg/gui/controllers/helpers/cherry_pick_helper.go11
-rw-r--r--pkg/gui/controllers/helpers/confirmation_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/credentials_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/diff_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/files_helper.go5
-rw-r--r--pkg/gui/controllers/helpers/gpg_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/helpers.go16
-rw-r--r--pkg/gui/controllers/helpers/host_helper.go5
-rw-r--r--pkg/gui/controllers/helpers/merge_and_rebase_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/merge_conflicts_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/patch_building_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/record_directory_helper.go6
-rw-r--r--pkg/gui/controllers/helpers/refresh_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/refs_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/repos_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/snake_helper.go5
-rw-r--r--pkg/gui/controllers/helpers/staging_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/suggestions_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/tags_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/update_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/upstream_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/view_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/window_helper.go4
-rw-r--r--pkg/gui/controllers/helpers/working_tree_helper.go4
-rw-r--r--pkg/gui/controllers/list_controller.go14
-rw-r--r--pkg/gui/controllers/local_commits_controller.go3
-rw-r--r--pkg/gui/gui.go14
-rw-r--r--pkg/gui/list_context_config.go26
-rw-r--r--pkg/gui/options_map.go3
-rw-r--r--pkg/gui/services/custom_commands/client.go2
-rw-r--r--pkg/gui/services/custom_commands/handler_creator.go5
-rw-r--r--pkg/gui/types/common.go4
55 files changed, 156 insertions, 133 deletions
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
index 81b289cec..1d6453c13 100644
--- a/pkg/gui/context/branches_context.go
+++ b/pkg/gui/context/branches_context.go
@@ -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 {
diff --git a/pkg/gui/context/commit_files_context.go b/pkg/gui/context/commit_files_context.go
index 80e3c52d0..0b884a7cd 100644
--- a/pkg/gui/context/commit_files_context.go
+++ b/pkg/gui/context/commit_files_context.go
@@ -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)
diff --git a/pkg/gui/context/commit_message_context.go b/pkg/gui/context/commit_message_context.go
index b7224341d..96c6c4f73 100644
--- a/pkg/gui/context/commit_message_context.go
+++ b/pkg/gui/context/commit_message_context.go
@@ -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,
diff --git a/pkg/gui/context/confirmation_context.go b/pkg/gui/context/confirmation_context.go
index 34ec3ce6f..69c498e49 100644
--- a/pkg/gui/context/confirmation_context.go
+++ b/pkg/gui/context/confirmation_context.go
@@ -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,
diff --git a/pkg/gui/context/context_common.go b/pkg/gui/context/context_common.go
new file mode 100644
index 000000000..9425280a4
--- /dev/null
+++ b/pkg/gui/context/context_common.go
@@ -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
+}
diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go
index df5bbc0af..d47a15c9c 100644
--- a/pkg/gui/context/list_context_trait.go
+++ b/pkg/gui/context/list_context_trait.go
@@ -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
}
diff --git a/pkg/gui/context/local_commits_context.go b/pkg/gui/context/local_commits_context.go
index 277e567ff..e8ae0b6c5 100644
--- a/pkg/gui/context/local_commits_context.go
+++ b/pkg/gui/context/local_commits_context.go
@@ -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
}
diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go
index 288016f8d..b2685b2e4 100644
--- a/pkg/gui/context/menu_context.go
+++ b/pkg/gui/context/menu_context.go
@@ -15,7 +15,7 @@ type MenuContext struct {
var _ types.IListContext = (*MenuContext)(nil)
func NewMenuContext(
- c *types.HelperCommon,
+ c *ContextCommon,
) *MenuContext {
viewModel := NewMenuViewModel()
diff --git a/pkg/gui/context/merge_conflicts_context.go b/pkg/gui/context/merge_conflicts_context.go
index 97024eedb..60aac6e3a 100644
--- a/pkg/gui/context/merge_conflicts_context.go
+++ b/pkg/gui/context/merge_conflicts_context.go
@@ -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(),
diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go
index 216381dcd..ccffb4f7e 100644
--- a/pkg/gui/context/patch_explorer_context.go
+++ b/pkg/gui/context/patch_explorer_context.go
@@ -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,
diff --git a/pkg/gui/context/reflog_commits_context.go b/pkg/gui/context/reflog_commits_context.go
index bb13038ec..40111beea 100644
--- a/pkg/gui/context/reflog_commits_context.go
+++ b/pkg/gui/context/reflog_commits_context.go
@@ -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 {
diff --git a/pkg/gui/context/remote_branches_context.go b/pkg/gui/context/remote_branches_context.go
index 474adb2a9..a085c18cc 100644
--- a/pkg/gui/context/remote_branches_context.go
+++ b/pkg/gui/context/remote_branches_context.go
@@ -18,7 +18,7 @@ var (
)
func NewRemoteBranchesContext(
- c *types.HelperCommon,
+ c *ContextCommon,
) *RemoteBranchesContext {
viewModel := NewBasicViewModel(func() []*models.RemoteBranch { return c.Model().RemoteBranches })
diff --git a/pkg/gui/context/remotes_context.go b/pkg/gui/context/remotes_context.go
index a194baec8..d1082ab52 100644
--- a/pkg/gui/context/remotes_context.go
+++ b/pkg/gui/context/remotes_context.go
@@ -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 {
diff --git a/pkg/gui/context/stash_context.go b/pkg/gui/context/stash_context.go
index f56abc561..386292c00 100644
--- a/pkg/gui/context/stash_context.go
+++ b/pkg/gui/context/stash_context.go
@@ -17,7 +17,7 @@ var (
)
func NewStashContext(
- c *types.HelperCommon,
+ c *ContextCommon,
) *StashContext {
viewModel := NewBasicViewModel(func() []*models.StashEntry { return c.Model().StashEntries })
diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go
index 0b75b37c2..16712f982 100644
--- a/pkg/gui/context/sub_commits_context.go
+++ b/pkg/gui/context/sub_commits_context.go
@@ -22,7 +22,7 @@ var (
)
func NewSubCommitsContext(
- c *types.HelperCommon,
+ c *ContextCommon,
) *SubCommitsContext {
viewModel := &SubCommitsViewModel{
BasicViewModel: NewBasicViewModel(
diff --git a/pkg/gui/context/submodules_context.go b/pkg/gui/context/submodules_context.go
index 5cd942284..675e01cd1 100644
--- a/pkg/gui/context/submodules_context.go
+++ b/pkg/gui/context/submodules_context.go
@@ -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 {
diff --git a/pkg/gui/context/suggestions_context.go b/pkg/gui/context/suggestions_context.go
index 744219843..022e96daf 100644
--- a/pkg/gui/context/suggestions_context.go
+++ b/pkg/gui/context/suggestions_context.go
@@ -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(),
diff --git a/pkg/gui/context/tags_context.go b/pkg/gui/context/tags_context.go
index 9722ece48..e49cdad9b 100644
--- a/pkg/gui/context/tags_context.go
+++ b/pkg/gui/context/tags_context.go
@@ -17,7 +17,7 @@ var (
)
func NewTagsContext(
- c *types.HelperCommon,
+ c *ContextCommon,
) *TagsContext {
viewModel := NewBasicViewModel(func() []*models.Tag { return c.Model().Tags })
diff --git a/pkg/gui/context/working_tree_context.go b/pkg/gui/context/working_tree_context.go
index 5cb73ad13..45502eb60 100644
--- a/pkg/gui/context/working_tree_context.go
+++ b/pkg/gui/context/working_tree_context.go
@@ -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,
diff --git a/pkg/gui/context_config.go b/pkg/gui/context_config.go
index 2c98478d9..8e59732c8 100644
--- a/pkg/gui/context_config.go
+++ b/pkg/gui/context_config.go
@@ -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,
diff --git a/pkg/gui/controllers.go b/pkg/gui/controllers.go
index f64710a70..b0520c975 100644
--- a/pkg/gui/controllers.go
+++ b/pkg/gui/controllers.go
@@ -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))
}
diff --git a/pkg/gui/controllers/common.go b/pkg/gui/controllers/common.go
index f3b3011d3..e1af81732 100644
--- a/pkg/gui/controllers/common.go
+++ b/pkg/gui/controllers/common.go
@@ -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,
diff --git a/pkg/gui/controllers/helpers/bisect_helper.go b/pkg/gui/controllers/helpers/bisect_helper.go
index 65fb781d4..7d0fadf8a 100644
--- a/pkg/gui/controllers/helpers/bisect_helper.go
+++ b/pkg/gui/controllers/helpers/bisect_helper.go
@@ -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)
}
diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go
index 84b77a299..695a726ae 100644
--- a/pkg/gui/controllers/helpers/cherry_pick_helper.go
+++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go
@@ -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,