summaryrefslogtreecommitdiffstats
path: root/pkg/gui/controllers/reflog_commits_controller.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-12-30 23:24:24 +1100
committerJesse Duffield <jessedduffield@gmail.com>2023-04-30 13:19:52 +1000
commit8edad826caf2fa48bfad33f9f8c4f3ba49a052da (patch)
tree0b49145e4f656e72441199b5a5c30176c898d7a7 /pkg/gui/controllers/reflog_commits_controller.go
parent826128a8e03fb50f7287029ebac93c85712faecb (diff)
Begin refactoring gui
This begins a big refactor of moving more code out of the Gui struct into contexts, controllers, and helpers. We also move some code into structs in the gui package purely for the sake of better encapsulation
Diffstat (limited to 'pkg/gui/controllers/reflog_commits_controller.go')
-rw-r--r--pkg/gui/controllers/reflog_commits_controller.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/pkg/gui/controllers/reflog_commits_controller.go b/pkg/gui/controllers/reflog_commits_controller.go
new file mode 100644
index 000000000..44cc50ab9
--- /dev/null
+++ b/pkg/gui/controllers/reflog_commits_controller.go
@@ -0,0 +1,53 @@
+package controllers
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/gui/context"
+ "github.com/jesseduffield/lazygit/pkg/gui/types"
+)
+
+type ReflogCommitsController struct {
+ baseController
+ *controllerCommon
+ context *context.ReflogCommitsContext
+}
+
+var _ types.IController = &ReflogCommitsController{}
+
+func NewReflogCommitsController(
+ common *controllerCommon,
+ context *context.ReflogCommitsContext,
+) *ReflogCommitsController {
+ return &ReflogCommitsController{
+ baseController: baseController{},
+ controllerCommon: common,
+ context: context,
+ }
+}
+
+func (self *ReflogCommitsController) Context() types.Context {
+ return self.context
+}
+
+func (self *ReflogCommitsController) GetOnRenderToMain() func() error {
+ return func() error {
+ return self.helpers.Diff.WithDiffModeCheck(func() error {
+ commit := self.context.GetSelected()
+ var task types.UpdateTask
+ if commit == nil {
+ task = types.NewRenderStringTask("No reflog history")
+ } else {
+ cmdObj := self.c.Git().Commit.ShowCmdObj(commit.Sha, self.c.Modes().Filtering.GetPath(), self.c.State().GetIgnoreWhitespaceInDiffView())
+
+ task = types.NewRunPtyTask(cmdObj.GetCmd())
+ }
+
+ return self.c.RenderToMainViews(types.RefreshMainOpts{
+ Pair: self.c.MainViewPairs().Normal,
+ Main: &types.ViewUpdateOpts{
+ Title: "Reflog Entry",
+ Task: task,
+ },
+ })
+ })
+ }
+}