diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-13 23:18:31 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:07:14 +1100 |
commit | e6be849eb2f01861ad29caa92595f32c2854bfb0 (patch) | |
tree | 3401bc68cc867a95181cc5a07702e8c518e5f33b /pkg/gui/branches_panel.go | |
parent | 092f27495a6b362537d2f8b7ff95bf29ee21f285 (diff) |
add remotes context to branches view
Diffstat (limited to 'pkg/gui/branches_panel.go')
-rw-r--r-- | pkg/gui/branches_panel.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index adea31072..205adf236 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -84,6 +84,10 @@ func (gui *Gui) RenderSelectedBranchUpstreamDifferences() error { // gui.refreshStatus is called at the end of this because that's when we can // be sure there is a state.Branches array to pick the current branch from func (gui *Gui) refreshBranches(g *gocui.Gui) error { + if err := gui.refreshRemotes(); err != nil { + return err + } + g.Update(func(g *gocui.Gui) error { builder, err := commands.NewBranchListBuilder(gui.Log, gui.GitCommand) if err != nil { @@ -358,3 +362,40 @@ func (gui *Gui) handleFastForward(g *gocui.Gui, v *gocui.View) error { }() return nil } + +func (gui *Gui) onBranchesTabClick(tabIndex int) error { + gui.State.Panels.Branches.ContextIndex = tabIndex + branchesView := gui.getBranchesView() + branchesView.TabIndex = tabIndex + + switch tabIndex { + case 0: + if err := gui.renderListPanel(branchesView, gui.State.Branches); err != nil { + return err + } + case 1: + if err := gui.renderListPanel(branchesView, gui.State.Remotes); err != nil { + return err + } + } + + return nil +} + +// gui.refreshStatus is called at the end of this because that's when we can +// be sure there is a state.Branches array to pick the current branch from +func (gui *Gui) refreshRemotes() error { + remotes, err := gui.GitCommand.GetRemotes() + if err != nil { + return gui.createErrorPanel(gui.g, err.Error()) + } + + gui.State.Remotes = remotes + + gui.g.Update(func(g *gocui.Gui) error { + gui.refreshSelectedLine(&gui.State.Panels.Remotes.SelectedLine, len(gui.State.Remotes)) + return nil + }) + + return nil +} |