summaryrefslogtreecommitdiffstats
path: root/pkg/gui/sub_commits_panel.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-01-16 14:46:53 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commit1dd7307fde033dae5fececac15810a99e26c3d91 (patch)
tree4e851c9e3229a6fe3b4191f6311d05d7a9142960 /pkg/gui/sub_commits_panel.go
parenta90b6efded49abcfa2516db794d7875b0396f558 (diff)
start moving commit panel handlers into controller
more and more move rebase commit refreshing into existing abstraction and more and more WIP and more handling clicks properly fix merge conflicts update cheatsheet lots more preparation to start moving things into controllers WIP better typing expand on remotes controller moving more code into controllers
Diffstat (limited to 'pkg/gui/sub_commits_panel.go')
-rw-r--r--pkg/gui/sub_commits_panel.go31
1 files changed, 19 insertions, 12 deletions
diff --git a/pkg/gui/sub_commits_panel.go b/pkg/gui/sub_commits_panel.go
index 97f57d158..c3b83d122 100644
--- a/pkg/gui/sub_commits_panel.go
+++ b/pkg/gui/sub_commits_panel.go
@@ -3,7 +3,9 @@ package gui
import (
"github.com/jesseduffield/lazygit/pkg/commands/loaders"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/controllers"
"github.com/jesseduffield/lazygit/pkg/gui/popup"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
)
// list panel functions
@@ -24,7 +26,7 @@ func (gui *Gui) subCommitsRenderToMain() error {
if commit == nil {
task = NewRenderStringTask("No commits")
} else {
- cmdObj := gui.Git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath())
+ cmdObj := gui.git.Commit.ShowCmdObj(commit.Sha, gui.State.Modes.Filtering.GetPath())
task = NewRunPtyTask(cmdObj.GetCmd())
}
@@ -43,19 +45,19 @@ func (gui *Gui) handleCheckoutSubCommit() error {
return nil
}
- err := gui.PopupHandler.Ask(popup.AskOpts{
- Title: gui.Tr.LcCheckoutCommit,
- Prompt: gui.Tr.SureCheckoutThisCommit,
+ err := gui.c.Ask(popup.AskOpts{
+ Title: gui.c.Tr.LcCheckoutCommit,
+ Prompt: gui.c.Tr.SureCheckoutThisCommit,
HandleConfirm: func() error {
- gui.logAction(gui.Tr.Actions.CheckoutCommit)
- return gui.handleCheckoutRef(commit.Sha, handleCheckoutRefOptions{})
+ gui.c.LogAction(gui.c.Tr.Actions.CheckoutCommit)
+ return gui.refHelper.CheckoutRef(commit.Sha, types.CheckoutRefOptions{})
},
})
if err != nil {
return err
}
- gui.State.Panels.SubCommits.SelectedLineIdx = 0
+ gui.State.Contexts.SubCommits.GetPanelState().SetSelectedLineIdx(0)
return nil
}
@@ -63,7 +65,7 @@ func (gui *Gui) handleCheckoutSubCommit() error {
func (gui *Gui) handleCreateSubCommitResetMenu() error {
commit := gui.getSelectedSubCommit()
- return gui.createResetMenu(commit.Sha)
+ return gui.refHelper.CreateGitResetMenu(commit.Sha)
}
func (gui *Gui) handleViewSubCommitFiles() error {
@@ -72,12 +74,17 @@ func (gui *Gui) handleViewSubCommitFiles() error {
return nil
}
- return gui.switchToCommitFilesContext(commit.Sha, false, gui.State.Contexts.SubCommits, "branches")
+ return gui.SwitchToCommitFilesContext(controllers.SwitchToCommitFilesContextOpts{
+ RefName: commit.Sha,
+ CanRebase: false,
+ Context: gui.State.Contexts.SubCommits,
+ WindowName: "branches",
+ })
}
func (gui *Gui) switchToSubCommitsContext(refName string) error {
// need to populate my sub commits
- commits, err := gui.Git.Loaders.Commits.GetCommits(
+ commits, err := gui.git.Loaders.Commits.GetCommits(
loaders.GetCommitsOptions{
Limit: gui.State.Panels.Commits.LimitCommits,
FilterPath: gui.State.Modes.Filtering.GetPath(),
@@ -91,10 +98,10 @@ func (gui *Gui) switchToSubCommitsContext(refName string) error {
gui.State.SubCommits = commits
gui.State.Panels.SubCommits.refName = refName
- gui.State.Panels.SubCommits.SelectedLineIdx = 0
+ gui.State.Contexts.SubCommits.GetPanelState().SetSelectedLineIdx(0)
gui.State.Contexts.SubCommits.SetParentContext(gui.currentSideListContext())
- return gui.pushContext(gui.State.Contexts.SubCommits)
+ return gui.c.PushContext(gui.State.Contexts.SubCommits)
}
func (gui *Gui) handleSwitchToSubCommits() error {