From 8edad826caf2fa48bfad33f9f8c4f3ba49a052da Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 30 Dec 2022 23:24:24 +1100 Subject: 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 --- pkg/gui/controllers/tags_controller.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'pkg/gui/controllers/tags_controller.go') diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index f4b23374c..a25c42f6a 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -56,6 +56,29 @@ func (self *TagsController) GetKeybindings(opts types.KeybindingsOpts) []*types. return bindings } +func (self *TagsController) GetOnRenderToMain() func() error { + return func() error { + return self.helpers.Diff.WithDiffModeCheck(func() error { + var task types.UpdateTask + tag := self.context().GetSelected() + if tag == nil { + task = types.NewRenderStringTask("No tags") + } else { + cmdObj := self.git.Branch.GetGraphCmdObj(tag.FullRefName()) + task = types.NewRunCommandTask(cmdObj.GetCmd()) + } + + return self.c.RenderToMainViews(types.RefreshMainOpts{ + Pair: self.c.MainViewPairs().Normal, + Main: &types.ViewUpdateOpts{ + Title: "Tag", + Task: task, + }, + }) + }) + } +} + func (self *TagsController) checkout(tag *models.Tag) error { self.c.LogAction(self.c.Tr.Actions.CheckoutTag) if err := self.helpers.Refs.CheckoutRef(tag.Name, types.CheckoutRefOptions{}); err != nil { -- cgit v1.2.3